http

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDispatcher

func NewDispatcher(client Client) (fiber.Dispatcher, error)

func NewHTTPResponse

func NewHTTPResponse(httpResponse *http.Response) fiber.Response

FromHTTP constructs a fiber http or error response from http response / error object

Types

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

Client is the base interface for an http-client (to be able to mock actual implementation)

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func (*Dispatcher) Do

func (d *Dispatcher) Do(req fiber.Request) fiber.Response

type Handler

type Handler struct {
	fiber.Component
	// contains filtered or unexported fields
}

Handler is a structure used to capture a fiber component and a set of options for making requests

func NewHandler

func NewHandler(c fiber.Component, options Options) *Handler

NewHandler is a creator factory for the Handler

func (*Handler) DoRequest

func (h *Handler) DoRequest(httpReq *http.Request) (fiber.Response, *fiberErrors.FiberError)

DoRequest executes the given http request and returns the response / error

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(writer http.ResponseWriter, httpReq *http.Request)

ServeHTTP takes an incoming request, dipatches it on the fiber component and writes the response using the given ResponseWriter

type Options

type Options struct {
	Timeout time.Duration
}

Options captures a set of options that can be used as configurations for the Request handler

type Request

type Request struct {
	*fiber.CachedPayload
	*http.Request
}

Request wraps a standard http request

func NewHTTPRequest

func NewHTTPRequest(req *http.Request) (*Request, error)

NewHTTPRequest initialize a new client request from incoming server request

func (*Request) Clone

func (r *Request) Clone() (fiber.Request, error)

Copy creates a deep copy of this request

func (*Request) Header

func (r *Request) Header() map[string][]string

func (*Request) OperationName

func (r *Request) OperationName() string

func (*Request) Protocol added in v0.2.0

func (r *Request) Protocol() protocol.Protocol

func (*Request) Transform

func (r *Request) Transform(backend fiber.Backend) (fiber.Request, error)

type Response

type Response struct {
	*fiber.CachedPayload
	// contains filtered or unexported fields
}

func (*Response) BackendName

func (r *Response) BackendName() string

BackendName returns the backend used to make the request

func (*Response) Header

func (r *Response) Header() http.Header

Header returns the response header

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

IsSuccess returns the success state of the request, which is true if the status

func (*Response) Label added in v0.2.0

func (r *Response) Label(key string) []string

Label returns all the values associated with the given key, in the response header. If the key does not exist, an empty slice will be returned.

func (*Response) StatusCode

func (r *Response) StatusCode() int

StatusCode returns the response status code

func (*Response) WithBackendName

func (r *Response) WithBackendName(backEnd string) fiber.Response

WithBackendName sets the given backend name in the response header. The modified response is returned.

func (*Response) WithLabel added in v0.2.0

func (r *Response) WithLabel(key string, values ...string) fiber.Response

WithLabel appends the given value(s) to the key, in the response header. If the key does not already exist, a new key will be created. The modified response is returned.

func (*Response) WithLabels added in v0.2.0

func (r *Response) WithLabels(labels fiber.Labels) fiber.Response

WithLabels does the same thing as WithLabel but over a collection of key-values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL