Documentation ¶
Index ¶
- Variables
- func BodyParameter(s spec.Schema) spec.Parameter
- func CreateResponses() *spec.Responses
- func DeleteResponses() *spec.Responses
- func Errored(w http.ResponseWriter, err error) bool
- func HandlerFunc(paths spec.Paths) http.HandlerFunc
- func PasswordHandlerFunc(accountReader security.AccountReader, f http.HandlerFunc) http.HandlerFunc
- func PathHandlerFunc(path string, f http.HandlerFunc) http.HandlerFunc
- func ReadResponses() *spec.Responses
- func Redact(pb proto.Message)
- func UpdateResponses() *spec.Responses
- func Validate(r *http.Request, o *spec.Operation, pb proto.Message) error
- func ValidateParameter(r http.Request, p spec.Parameter) (string, error)
- func ValidateParameterQueryAction(r http.Request, ps ...spec.Parameter) string
- func WriteProto(w http.ResponseWriter, pb proto.Message)
- func WriteProtoCreated(w http.ResponseWriter, pb proto.Message, location string)
- func WriteProtos(w http.ResponseWriter, pbs []proto.Message)
- type HeaderHandler
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
var ( errors.New(http.StatusText(http.StatusForbidden)) // ErrNotFound not found error ErrNotFound = errors.New(http.StatusText(http.StatusNotFound)) // ErrInvalid invalid error ErrInvalid = errors.New("invalid") // ErrDuplicate duplicate error ErrDuplicate = errors.New("duplicate") // ErrMethodNotAllowed HTTP method not allowed ErrMethodNotAllowed = errors.New(http.StatusText(http.StatusMethodNotAllowed)) )ErrUnauthorized =
Functions ¶
func BodyParameter ¶
BodyParameter body parameter with Required true
func CreateResponses ¶
CreateResponses responses for create operation
func DeleteResponses ¶
DeleteResponses responses for delete operation
func Errored ¶
func Errored(w http.ResponseWriter, err error) bool
Errored writes errors to the HTTP response writer
func HandlerFunc ¶
func HandlerFunc(paths spec.Paths) http.HandlerFunc
HandlerFunc writes the spec as json
func PasswordHandlerFunc ¶
func PasswordHandlerFunc(accountReader security.AccountReader, f http.HandlerFunc) http.HandlerFunc
PasswordHandlerFunc request.Form must be initialized before
func PathHandlerFunc ¶
func PathHandlerFunc(path string, f http.HandlerFunc) http.HandlerFunc
PathHandlerFunc supports single path parameter only /path/{parameter} calls http.HandleFunc with DefaultServeMux path reference https://www.reddit.com/r/golang/comments/3z10p1/create_dynamic_paths_in_httphandle_with_only/cyicw0t
func ReadResponses ¶
ReadResponses responses for read operation
func UpdateResponses ¶
UpdateResponses responses for update operation
func ValidateParameter ¶
ValidateParameter path and query parameters
func ValidateParameterQueryAction ¶
ValidateParameterQueryAction query parameter for actions, no value, not required
func WriteProto ¶
func WriteProto(w http.ResponseWriter, pb proto.Message)
WriteProto jsonpb marshal a proto
func WriteProtoCreated ¶
func WriteProtoCreated(w http.ResponseWriter, pb proto.Message, location string)
WriteProtoCreated sets 201 and Location header
func WriteProtos ¶
func WriteProtos(w http.ResponseWriter, pbs []proto.Message)
WriteProtos marshal many protos
Types ¶
type HeaderHandler ¶
HeaderHandler adds HTTP headers
func (HeaderHandler) ServeHTTP ¶
func (h HeaderHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ValidationError ¶
type ValidationError struct { Property string `json:"property,omitempty"` Rule string `json:"rule,omitempty"` }
ValidationError with JSON tags
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors returned to the user
func (ValidationErrors) Error ¶
func (e ValidationErrors) Error() string