Documentation
¶
Overview ¶
Package socket provides common implementations for local APIs that use HTTP over Unix domain sockets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateToken ¶
GenerateToken generates a new random token that contains approximately 8*len bits of entropy.
func HeadersMiddleware ¶
HeadersMiddleware is a middleware that sets common headers for all responses.
Types ¶
type APIErr ¶
APIErr is an error type used for API error responses (the API returned a well-formed JSON ErrorResponse and a non-200 status code).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for a HTTP-over-Unix Domain Socket API.
func NewClient ¶
NewClient creates a new Client. The context is used for an internal check that the socket can be dialled.
func (*Client) Do ¶
Do implements the common bits of an API call. req is serialised to JSON and passed as the request body if not nil. The method is called, with the token added in the Authorization header. The response is deserialised, either into the object passed into resp if the status is 200 OK, otherwise into an error.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
Error response is the response body for any errors that occur
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server hosts a HTTP server on a Unix domain socket.
func NewServer ¶
NewServer creates a server that, when started, will listen on a socket at the given path.