Documentation ¶
Overview ¶
Contains "core"-level helper code to build APIs. These should be reusable in building any API for our platform, and should not contain specific PIXLISE API business logic
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToJSON ¶
func ToJSON(w http.ResponseWriter, v interface{})
Types ¶
type Error ¶
Error represents a handler error. It provides methods for a HTTP status code and embeds the built-in error interface.
type JWTInterface ¶
type JWTInterface interface { ValidateRequest(r *http.Request) (*jwt.JSONWebToken, error) Claims(r *http.Request, token *jwt.JSONWebToken, values ...interface{}) error }
Implements a JWT validation and claim extraction interface
type MockJWTValidator ¶
type MockJWTValidator struct { }
func (*MockJWTValidator) Claims ¶
func (v *MockJWTValidator) Claims(r *http.Request, token *jwt.JSONWebToken, values ...interface{}) error
func (*MockJWTValidator) ValidateRequest ¶
func (v *MockJWTValidator) ValidateRequest(r *http.Request) (*jwt.JSONWebToken, error)
type RealJWTReader ¶
type RealJWTReader struct {
Validator JWTInterface
}
RealJWTReader - Reader
func (RealJWTReader) GetSimpleUserInfo ¶
GetSimpleUserInfo - Get Simple User Info
func (RealJWTReader) GetUserInfo ¶
GetUserInfo - Get User Info
type ResponseWriterWithCopy ¶
type ResponseWriterWithCopy struct { RealWriter http.ResponseWriter Body *bytes.Buffer Status int }
ResponseWriterWithCopy - Acts like a normal http response writer but stores a copy of the written bytes/status, so it can be logged/monitored by a middleware component
func (*ResponseWriterWithCopy) Header ¶
func (w *ResponseWriterWithCopy) Header() http.Header
func (*ResponseWriterWithCopy) StatusText ¶
func (w *ResponseWriterWithCopy) StatusText() string
func (*ResponseWriterWithCopy) Write ¶
func (w *ResponseWriterWithCopy) Write(p []byte) (int, error)
func (*ResponseWriterWithCopy) WriteHeader ¶
func (w *ResponseWriterWithCopy) WriteHeader(statusCode int)
type StatusError ¶
api.StatusError represents an error with an associated HTTP status code.
func MakeBadRequestError ¶
func MakeBadRequestError(err error) StatusError
func MakeStatusError ¶
func MakeStatusError(code int, err error) StatusError
Mainly so we don't get a bunch of errors for not using field names in StatusError{}
func (StatusError) Error ¶
func (se StatusError) Error() string
Allows api.StatusError to satisfy the error interface.
func (StatusError) Status ¶
func (se StatusError) Status() int
Status - Returns our HTTP status code.