Documentation
¶
Index ¶
- func LoadCertificates(certificates []string) (*x509.CertPool, error)
- type APIClient
- type APIError
- type APIErrorData
- type APIRequestError
- type Client
- func (c *Client) DialTLSContext(ctx context.Context, network, address string) (net.Conn, error)
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) SendRequest(method string, uri *url.URL, header map[string]string, body io.Reader) (*http.Response, error)
- func (c *Client) Terminate()
- type ClientCfg
- type ErrorHandler
- type Handler
- func (h *Handler) HasQueryParameter(name string) bool
- func (h *Handler) JSONRequestData(dest interface{}) error
- func (h *Handler) JSONRequestObject(obj check.Object) error
- func (h *Handler) JSONRequestObject2(obj check.Object, fn func(*check.Checker)) error
- func (h *Handler) QueryParameter(name string) string
- func (h *Handler) Reply(status int, r io.Reader)
- func (h *Handler) ReplyCompactJSON(status int, value interface{})
- func (h *Handler) ReplyEmpty(status int)
- func (h *Handler) ReplyError(status int, code, format string, args ...interface{})
- func (h *Handler) ReplyErrorData(status int, code string, data APIErrorData, format string, args ...interface{})
- func (h *Handler) ReplyInternalError(status int, format string, args ...interface{})
- func (h *Handler) ReplyJSON(status int, value interface{})
- func (h *Handler) ReplyNotImplemented(feature string)
- func (h *Handler) ReplyRedirect(status int, uri string)
- func (h *Handler) ReplyRequestBodyValidationErrors(err check.ValidationErrors)
- func (h *Handler) RequestData() ([]byte, error)
- func (h *Handler) RouteVariable(name string) string
- type InvalidQueryParameterError
- type ResponseWriter
- type RoundTripper
- type RouteFunc
- type Server
- type ServerCfg
- type TLSClientCfg
- type TLSServerCfg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIClient ¶
type APIClient struct {
*Client
}
func NewAPIClient ¶
func (*APIClient) SendJSONRequest ¶
type APIError ¶
type APIError struct {
Message string `json:"error"`
Code string `json:"code,omitempty"`
Data APIErrorData `json:"data,omitempty"`
}
type APIErrorData ¶
type APIErrorData map[string]interface{}
type APIRequestError ¶
func (APIRequestError) Error ¶
func (err APIRequestError) Error() string
type Client ¶
type Client struct {
Cfg ClientCfg
Log *dlog.Logger
Client *http.Client
// contains filtered or unexported fields
}
func (*Client) DialTLSContext ¶
func (*Client) SendRequest ¶
type ClientCfg ¶
type ErrorHandler ¶
type ErrorHandler func(*Handler, int, string, string, APIErrorData)
type Handler ¶
type Handler struct {
Server *Server
Log *dlog.Logger
ClientAddress string
RequestId string
Pattern string
Method string
RouteId string
Query url.Values
Request *http.Request
ResponseWriter http.ResponseWriter
StartTime time.Time
// contains filtered or unexported fields
}
func (*Handler) HasQueryParameter ¶
func (*Handler) JSONRequestData ¶
func (*Handler) JSONRequestObject2 ¶
func (*Handler) QueryParameter ¶
func (*Handler) ReplyCompactJSON ¶
func (*Handler) ReplyEmpty ¶
func (*Handler) ReplyError ¶
func (*Handler) ReplyErrorData ¶
func (h *Handler) ReplyErrorData(status int, code string, data APIErrorData, format string, args ...interface{})
func (*Handler) ReplyInternalError ¶
func (*Handler) ReplyNotImplemented ¶
func (*Handler) ReplyRedirect ¶
func (*Handler) ReplyRequestBodyValidationErrors ¶
func (h *Handler) ReplyRequestBodyValidationErrors(err check.ValidationErrors)
func (*Handler) RequestData ¶
func (*Handler) RouteVariable ¶
type InvalidQueryParameterError ¶
func NewInvalidQueryParameterError ¶
func NewInvalidQueryParameterError(name, format string, args ...interface{}) *InvalidQueryParameterError
func (InvalidQueryParameterError) Error ¶
func (err InvalidQueryParameterError) Error() string
type ResponseWriter ¶
type ResponseWriter struct {
Status int
ResponseBodySize int
// contains filtered or unexported fields
}
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) *ResponseWriter
func (*ResponseWriter) Header ¶
func (w *ResponseWriter) Header() http.Header
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(status int)
type RoundTripper ¶
type RoundTripper struct {
Cfg *ClientCfg
Log *dlog.Logger
http.RoundTripper
}
func NewRoundTripper ¶
func NewRoundTripper(rt http.RoundTripper, cfg *ClientCfg) *RoundTripper
type Server ¶
type ServerCfg ¶
type ServerCfg struct {
Log *dlog.Logger `json:"-"`
ErrorChan chan<- error `json:"-"`
ErrorHandler ErrorHandler `json:"-"`
Address string `json:"address"`
TLS *TLSServerCfg `json:"tls,omitempty"`
HideInternalErrors bool `json:"hide_internal_errors"`
HideSuccessfulRequests bool `json:"hide_successful_requests"`
}
type TLSClientCfg ¶
type TLSClientCfg struct {
CACertificates []string `json:"ca_certificates"`
PublicKeyPins map[string][]string `json:"public_key_pins"`
}
func (*TLSClientCfg) Check ¶
func (cfg *TLSClientCfg) Check(c *check.Checker)
type TLSServerCfg ¶
type TLSServerCfg struct {
Certificate string `json:"certificate"`
PrivateKey string `json:"private_key"`
}
func (*TLSServerCfg) Check ¶
func (cfg *TLSServerCfg) Check(c *check.Checker)
Click to show internal directories.
Click to hide internal directories.