https://github.com/maprost/restclient
Rest client for go, handels json and xml http requests.
https://github.com/maprost/restclient
go golang restclient
Last synced: 5 months ago
JSON representation
Rest client for go, handels json and xml http requests.
- Host: GitHub
- URL: https://github.com/maprost/restclient
- Owner: maprost
- Created: 2017-04-05T11:28:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-23T04:29:58.000Z (over 3 years ago)
- Last Synced: 2025-03-13T09:39:00.544Z (over 1 year ago)
- Topics: go, golang, restclient
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/maprost/restclient)
[](https://coveralls.io/github/maprost/restclient)
[](https://godoc.org/github.com/maprost/restclient)
[](https://goreportcard.com/report/github.com/maprost/restclient)
# RestClient
## Install
```
go get github.com/maprost/restclient
```
## Supported Methods
- Get
- Post
- Put
- Delete
## Supported Format
- Json
- XML
## Features
- custom logger
- query builder
## Usage
```go
var users []User
result := restclient.Get(serverUrl + "/user").
AddQueryParam("limit", 1).
AddQueryParam("email", "example@gmail.com").
SendAndGetJsonResponse(&users)
// check internal rest client error
if result.Err != nil {
return result.Err
}
// check response error
if result.StatusCode != 200 {
return errors.New(result.ResponseError)
}
// or check both at once
if err := result.Error(); err != nil {
return err
}
```
```go
var users []User
result := restclient.Get(serverUrl + "/user" + rcquery.New().Add("limit", 1).Get()).
SendAndGetJsonResponse(&users)
if err := result.Error(); err != nil {
return err
}
```
```go
var user User{/* init */}
result := restclient.Post(serverUrl + "/user").
AddJsonBody(user).
Send()
if err := result.Error(); err != nil {
return err
}
```