Documentation ¶
Index ¶
- type ErrorType
- type JSONArray
- type JSONBody
- type Pantopoda
- func (c *Pantopoda) Delete(endpoint string, request Request) (Response, error)
- func (c *Pantopoda) Get(endpoint string, request Request) (Response, error)
- func (c *Pantopoda) Patch(endpoint string, request Request) (Response, error)
- func (c *Pantopoda) Post(endpoint string, request Request) (Response, error)
- func (c *Pantopoda) Put(endpoint string, request Request) (Response, error)
- func (c *Pantopoda) Request(method string, endpoint string, request Request) (Response, error)
- type QueryParams
- type Request
- type RequestBody
- type RequestData
- type RequestHeaders
- type Response
- type ResponseError
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorType ¶ added in v0.2.0
type ErrorType string
ErrorType is a string subtype used inside ValidationError type which determines the type of validation error. There are two type of validation errors; BadRequest, that returned when the request payload did not match with request data structure. And RuleViolation, that returned when any of specified rules in validation tag violated in incoming request payload.
const BadRequest ErrorType = "bad_request"
BadRequest that returned when the request payload did not match with request data structure
const RuleViolation ErrorType = "validation_failed"
RuleViolation that returned when any of specified rules in validation tags violated in incoming request payload.
type JSONArray ¶ added in v0.2.1
type JSONArray []JSONBody
JSONArray represents the body with an array of json objects.
type JSONBody ¶ added in v0.2.1
type JSONBody map[string]interface{}
JSONBody represents the json object body.
type Pantopoda ¶ added in v0.2.0
type Pantopoda struct { }
Pantopoda is a HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.
func NewPantopoda ¶ added in v0.2.0
func NewPantopoda() *Pantopoda
NewPantopoda generate new instance of pantopoda client
func (*Pantopoda) Delete ¶ added in v0.2.0
Delete sends a DELETE request to `endpoint` with given given data.
func (*Pantopoda) Patch ¶ added in v0.2.0
Patch sends a PATCH request to `endpoint` with given given data.
type QueryParams ¶ added in v0.2.0
QueryParams represent url query params.
func (QueryParams) Empty ¶ added in v0.2.0
func (q QueryParams) Empty() bool
Empty checks if query param is empty.
func (QueryParams) ToString ¶ added in v0.2.0
func (q QueryParams) ToString() string
ToString converts QueryParams map to its string representation.
type Request ¶ added in v0.2.0
type Request struct { // Payload represent json body of HTTP call. Payload RequestBody // Query represent query params of HTTP call endpoint. Query QueryParams // Headers represent headers of HTTP call. Headers RequestHeaders }
Request represent all data such as payload, query params, and header of a JSON HTTP request call.
type RequestBody ¶ added in v0.2.0
type RequestBody interface {
ToJSON() []byte
}
RequestBody represents the json body in an HTTP request body.
type RequestData ¶
type RequestData interface { nautilus.Taggable // Validate runs request data validation and returns validation error if Validate() ValidationError }
RequestData is an interface for incoming request payload
type RequestHeaders ¶ added in v0.2.0
RequestHeaders represents the key-value pairs in an HTTP header.
type Response ¶ added in v0.2.0
type Response struct { StatusCode code.StatusCode Headers http.Header // contains filtered or unexported fields }
Response represents HTTP call response body.
type ResponseError ¶ added in v0.3.1
ResponseError is an error implementation for client and server errors in API calls.
func (ResponseError) Error ¶ added in v0.3.1
func (e ResponseError) Error() string
type ValidationError ¶ added in v0.2.0
type ValidationError struct { // ErrorBag contains any validation errors on request fields. ErrorBag shark.ErrorBag // ErrorType is a string determine type of the validation error. ErrorType ErrorType }
ValidationError is an error type containing validation error bag and error type determine type of validation error.
func Validate ¶ added in v0.2.0
func Validate(r RequestData) ValidationError
Validate runs request data validation and returns validation error