Documentation
¶
Index ¶
- Variables
- type QueryInterface
- type RESTClient
- type Request
- func (r *Request) APIPrefix(apiPrefix string) *Request
- func (r *Request) APIVersion(APIVersion string) *Request
- func (r *Request) Body(obj any) *Request
- func (r *Request) Do() *Response
- func (r *Request) Name(name string) *Request
- func (r *Request) Project(project string) *Request
- func (r *Request) Query(query QueryInterface) *Request
- func (r *Request) Resource(resource string) *Request
- type RequestError
- type Response
Constants ¶
This section is empty.
Variables ¶
var ( RequestInternalError = &RequestError{Message: "internal server error", StatusCode: http.StatusInternalServerError} RequestNotFoundError = &RequestError{Message: "document not found", StatusCode: http.StatusNotFound} ConflictError = &RequestError{Message: "document already exists", StatusCode: http.StatusConflict} )
Functions ¶
This section is empty.
Types ¶
type QueryInterface ¶
QueryInterface defines the query interface that you can set in the Request
type RESTClient ¶
type RESTClient struct {
// Default headers for all client requests (not editable)
Headers map[string]string
// base is the root URL for all invocations of the client
BaseURL *common.URL
// Set specific behavior of the client. If not, set http.DefaultClient will be used.
Client *http.Client
}
RESTClient defines an HTTP client designed for the HTTP request to a REST API.
func (*RESTClient) Delete ¶
func (c *RESTClient) Delete() *Request
Delete begins a Delete request. Short for c.newRequest("DELETE")
func (*RESTClient) Get ¶
func (c *RESTClient) Get() *Request
Get begins a GET request. Short for c.newRequest("GET")
func (*RESTClient) Patch ¶
func (c *RESTClient) Patch() *Request
Patch begins a Patch request. Short for c.newRequest("PATCH")
func (*RESTClient) Post ¶
func (c *RESTClient) Post() *Request
Post begins a Post request. Short for c.newRequest("POST")
func (*RESTClient) Put ¶
func (c *RESTClient) Put() *Request
Put begins a Put request. Short for c.newRequest("PUT")
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request allows for building up a request to a server in a chained fashion. Any errors are stored until the end of your call, so you only have to check once.
func NewRequest ¶
func NewRequest(client *http.Client, method string, baseURL *common.URL, headers map[string]string) *Request
NewRequest creates a new request helper object for accessing resource on the API
func (*Request) APIVersion ¶
APIVersion set the api version to used (default v1)
func (*Request) Do ¶
Do build the query and execute it. The error and/or the response from the server are set in the object Response
func (*Request) Project ¶
Project set the project where the resource must be defined. It cannot be used at the same time with Request.Area
func (*Request) Query ¶
func (r *Request) Query(query QueryInterface) *Request
Query set all queryParameter contains in the query passed as a parameter
type RequestError ¶
RequestError is a format struct to defines the error the results of calling #Request.Do()
func (*RequestError) Error ¶
func (re *RequestError) Error() string
func (*RequestError) Unwrap ¶
func (re *RequestError) Unwrap() error