Documentation
¶
Index ¶
- type Option
- type XiiClient
- type XiiMiddleware
- type XiiRequest
- func (req *XiiRequest) Body(body io.Reader) *XiiRequest
- func (req *XiiRequest) Context(ctx context.Context) *XiiRequest
- func (req *XiiRequest) DELETE(endpoint string) *XiiRequest
- func (req *XiiRequest) Endpoint(endpoint string) *XiiRequest
- func (req *XiiRequest) FormBody(formData url.Values) *XiiRequest
- func (req *XiiRequest) GET(endpoint string) *XiiRequest
- func (req *XiiRequest) GetHeaders() map[string][]string
- func (req *XiiRequest) Header(key, value string) *XiiRequest
- func (req *XiiRequest) JSONBody(jsonData any) *XiiRequest
- func (req *XiiRequest) Method(method string) *XiiRequest
- func (req *XiiRequest) MultipartFormBody(formData url.Values) *XiiRequest
- func (req *XiiRequest) PATCH(endpoint string) *XiiRequest
- func (req *XiiRequest) POST(endpoint string) *XiiRequest
- func (req *XiiRequest) PUT(endpoint string) *XiiRequest
- func (req *XiiRequest) QueryParam(key, value string) *XiiRequest
- func (req *XiiRequest) TextBody(text string) *XiiRequest
- func (req *XiiRequest) XMLBody(xmlData any) *XiiRequest
- func (req *XiiRequest) YAMLBody(yamlData any) *XiiRequest
- type XiiResponse
- func (resp *XiiResponse) IsClientError() bool
- func (resp *XiiResponse) IsError() bool
- func (resp *XiiResponse) IsRedirect() bool
- func (resp *XiiResponse) IsServerError() bool
- func (resp *XiiResponse) IsSuccess() bool
- func (resp *XiiResponse) JSONBody(v any) error
- func (resp *XiiResponse) TextBody() string
- func (resp *XiiResponse) XMLBody(v any) error
- func (resp *XiiResponse) YAMLBody(v any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*XiiClient)
Option is a function that modifies the XiiClient.
func WithBaseURL ¶
WithBaseURL sets the base URL for the XiiClient.
func WithHeader ¶
WithHeader sets a header for the XiiClient.
func WithTimeout ¶
WithTimeout sets the timeout for the XiiClient.
type XiiClient ¶
type XiiClient struct {
// contains filtered or unexported fields
}
XiiClient is a client for making HTTP requests.
func (*XiiClient) Do ¶
func (c *XiiClient) Do(req *XiiRequest) (*XiiResponse, error)
Do sends an HTTP request and returns an HTTP response.
func (*XiiClient) Use ¶
func (c *XiiClient) Use(mw XiiMiddleware)
Use adds a middleware to the XiiClient.
type XiiMiddleware ¶
XiiMiddleware is a function that modifies the HTTP request before it is sent.
type XiiRequest ¶
type XiiRequest struct {
// contains filtered or unexported fields
}
XiiRequest represents an HTTP request with various configurable options.
func NewXiiRequest ¶
func NewXiiRequest() *XiiRequest
NewXiiRequest creates a new XiiRequest with default values.
func (*XiiRequest) Body ¶
func (req *XiiRequest) Body(body io.Reader) *XiiRequest
Body sets the request body to the provided io.Reader.
func (*XiiRequest) Context ¶
func (req *XiiRequest) Context(ctx context.Context) *XiiRequest
Context sets the request context.
func (*XiiRequest) DELETE ¶
func (req *XiiRequest) DELETE(endpoint string) *XiiRequest
Shortcut methods for DELETE requests
func (*XiiRequest) Endpoint ¶
func (req *XiiRequest) Endpoint(endpoint string) *XiiRequest
Endpoint sets the request endpoint.
func (*XiiRequest) FormBody ¶
func (req *XiiRequest) FormBody(formData url.Values) *XiiRequest
FormBody sets the request body to the form-urlencoded representation of formData.
func (*XiiRequest) GET ¶
func (req *XiiRequest) GET(endpoint string) *XiiRequest
Shortcut methods for GET requests
func (*XiiRequest) GetHeaders ¶
func (req *XiiRequest) GetHeaders() map[string][]string
GetHeaders returns the headers of the request.
func (*XiiRequest) Header ¶
func (req *XiiRequest) Header(key, value string) *XiiRequest
Header adds a header to the request.
func (*XiiRequest) JSONBody ¶
func (req *XiiRequest) JSONBody(jsonData any) *XiiRequest
JSONBody sets the request body to the JSON representation of jsonData.
func (*XiiRequest) Method ¶
func (req *XiiRequest) Method(method string) *XiiRequest
Method sets the request method.
func (*XiiRequest) MultipartFormBody ¶
func (req *XiiRequest) MultipartFormBody(formData url.Values) *XiiRequest
MultipartFormBody sets the request body to the multipart form representation of formData.
func (*XiiRequest) PATCH ¶
func (req *XiiRequest) PATCH(endpoint string) *XiiRequest
Shortcut methods for PATCH requests
func (*XiiRequest) POST ¶
func (req *XiiRequest) POST(endpoint string) *XiiRequest
Shortcut methods for POST requests
func (*XiiRequest) PUT ¶
func (req *XiiRequest) PUT(endpoint string) *XiiRequest
Shortcut methods for PUT requests
func (*XiiRequest) QueryParam ¶
func (req *XiiRequest) QueryParam(key, value string) *XiiRequest
QueryParam adds a query parameter to the request.
func (*XiiRequest) TextBody ¶
func (req *XiiRequest) TextBody(text string) *XiiRequest
TextBody sets the request body to the plain text representation of text.
func (*XiiRequest) XMLBody ¶
func (req *XiiRequest) XMLBody(xmlData any) *XiiRequest
XMLBody sets the request body to the XML representation of xmlData.
func (*XiiRequest) YAMLBody ¶
func (req *XiiRequest) YAMLBody(yamlData any) *XiiRequest
YAMLBody sets the request body to the YAML representation of yamlData.
type XiiResponse ¶
type XiiResponse struct {
Request *XiiRequest
StatusCode int
Proto string
Headers http.Header
Body []byte
}
XiiResponse represents an HTTP response with various configurable options.
func (*XiiResponse) IsClientError ¶
func (resp *XiiResponse) IsClientError() bool
IsClientError returns true if the response status code is in the 4xx range.
func (*XiiResponse) IsError ¶
func (resp *XiiResponse) IsError() bool
IsError returns true if the response status code is in the 4xx or 5xx range.
func (*XiiResponse) IsRedirect ¶
func (resp *XiiResponse) IsRedirect() bool
IsRedirect returns true if the response status code is in the 3xx range.
func (*XiiResponse) IsServerError ¶
func (resp *XiiResponse) IsServerError() bool
IsServerError returns true if the response status code is in the 5xx range.
func (*XiiResponse) IsSuccess ¶
func (resp *XiiResponse) IsSuccess() bool
IsSuccess returns true if the response status code is in the 2xx range.
func (*XiiResponse) JSONBody ¶
func (resp *XiiResponse) JSONBody(v any) error
JSONBody unmarshals the response body into the provided struct.
func (*XiiResponse) TextBody ¶
func (resp *XiiResponse) TextBody() string
TextBody returns the response body as a string.
func (*XiiResponse) XMLBody ¶
func (resp *XiiResponse) XMLBody(v any) error
XMLBody unmarshals the response body into the provided struct.
func (*XiiResponse) YAMLBody ¶
func (resp *XiiResponse) YAMLBody(v any) error
YAMLBody unmarshals the response body into the provided struct.