Documentation
¶
Index ¶
- func HTTPError(code int, f any, a ...any) error
- func Handler(handler any, permFuncs ...func(*Request) bool) http.Handler
- type Client
- func (c *Client) Delete(url string, dest any) error
- func (c *Client) DisallowUnknownFields() *Client
- func (c *Client) Get(url string, dest any) error
- func (c *Client) Post(url string, data any, dest any) error
- func (c *Client) Put(url string, data any, dest any) error
- func (c *Client) Request(method, URL string, data any, dest any) error
- func (c *Client) WithHeaderToken(ht string) *Client
- func (c *Client) WithParamToken(pt string) *Client
- func (c *Client) WithToken(tk string) *Client
- func (c *Client) WithTokenPrefix(tp string) *Client
- type Request
- type Server
- func (s *Server) AddMiddleware(f func(next http.Handler) http.Handler)
- func (s *Server) Get(key string) any
- func (s *Server) Handle(pattern string, handler any, permFuncs ...func(*Request) bool)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Set(key string, value any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
Handler registers a http.Handler from a handler function.
handler must be a function with one of these signatures:
- http.Handler
- func (http.ResponseWriter, *http.Request)
- func [Input, Output any] (*Request, Input) (Output, error)
- func [Output any] (*Request) (Output, error)
If there are permFuncs, at least one of them must succeed.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a way to connect to 3rd party API servers.
func (*Client) DisallowUnknownFields ¶ added in v0.0.2
DisallowUnknownFields causes the JSON decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.
func (*Client) Request ¶
Request makes a HTTP request to the API. If data is not a []byte, it will be encoding as a JSON object.
func (*Client) WithHeaderToken ¶
WithHeaderToken specifies which Header line to use when sending a token.
func (*Client) WithParamToken ¶
WithParamToken specifies which query parameter to use when sending a token.
func (*Client) WithTokenPrefix ¶
WithTokenPrefix adds an optional prefix to the token in the Header line.
type Request ¶
Request encapsulates a *http.Request to be able to use the Get and Set methods.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an HTTP request multiplexer.
func (*Server) AddMiddleware ¶
AddMiddleware adds a new middleware to the Server. This should only be called before the first call to ServeHTTP.
func (*Server) Handle ¶
Handle registers a handler in the server.
handler must be a function with one of these signatures:
- http.Handler
- func (http.ResponseWriter, *http.Request)
- func [Input, Output any] (*Request, Input) (Output, error)
- func [Output any] (*Request) (Output, error)
If there are permFuncs, at least one of them must succeed.