Documentation ¶
Index ¶
- func Failure(w http.ResponseWriter, status int, err ErrorMessage)
- func FailureFromError(w http.ResponseWriter, status int, err error)
- func FailureFromValidator(w http.ResponseWriter, result *validate.Result)
- func InternalServerFailure(w http.ResponseWriter, r *http.Request, p interface{})
- func JSON(w http.ResponseWriter, code int, body interface{})
- func MethodNotAllowedFailure(w http.ResponseWriter, r *http.Request)
- func NewErrSchemaFileFormatNotSupported(ext string) error
- func NewErrSchemaNotFound(name string) error
- func NotFoundFailure(w http.ResponseWriter, r *http.Request)
- func ResponseStatus(w http.ResponseWriter) int
- func ServiceUnavailableFailure(w http.ResponseWriter, retry time.Duration)
- type Controller
- type ErrSchemaFileFormatNotSupported
- type ErrSchemaNotFound
- type ErrorMessage
- type ErrorMessageInterface
- type ErrorResponse
- type ErrorsResponse
- type HealthCheckHandler
- type HealthCheckResponse
- type Router
- func (r *Router) AddController(controller Controller)
- func (r *Router) AddHealthCheck(name string, handle HealthCheckHandler) error
- func (r *Router) AddPrefixRoute(prefix string, handler http.Handler) *mux.Route
- func (r *Router) AddPrefixRouteFunc(prefix string, handler http.HandlerFunc) *mux.Route
- func (r *Router) AddRoute(path string, handler http.Handler) *mux.Route
- func (r *Router) AddRouteFunc(path string, handler http.HandlerFunc) *mux.Route
- func (r *Router) EnableCors()
- func (r *Router) EnableCorsWithOptions(options cors.Options)
- func (r *Router) EnableHealthCheck()
- func (r *Router) EnableMetrics()
- func (r *Router) EnableRecovery()
- func (r *Router) SetNotFound(handler http.Handler)
- func (r *Router) SetNotFoundFunc(handler http.HandlerFunc)
- func (r *Router) Use(middleware ...alice.Constructor)
- type SchemaValidator
- type Validator
- func (v *Validator) AddSchemFromObject(object SchemaValidator) error
- func (v *Validator) AddSchemFromObjectName(name string, object SchemaValidator) error
- func (v *Validator) AddSchema(name string, schema *spec.Schema) error
- func (v *Validator) AddSchemaFromFile(name string, filename string) error
- func (v *Validator) AddSchemaFromJSON(name string, content json.RawMessage) error
- func (v *Validator) AddSchemaFromReader(name string, format string, reader io.Reader) error
- func (v *Validator) AddSchemaFromYAML(name string, content []byte) error
- func (v Validator) Validate(name string, data interface{}) *validate.Result
- type ValidatorError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FailureFromError ¶
func FailureFromError(w http.ResponseWriter, status int, err error)
FailureFromError write ErrorMessage from error
func FailureFromValidator ¶
func FailureFromValidator(w http.ResponseWriter, result *validate.Result)
FailureFromValidator response
func InternalServerFailure ¶
func InternalServerFailure(w http.ResponseWriter, r *http.Request, p interface{})
InternalServerFailure response
func MethodNotAllowedFailure ¶
func MethodNotAllowedFailure(w http.ResponseWriter, r *http.Request)
MethodNotAllowedFailure response
func NewErrSchemaFileFormatNotSupported ¶
NewErrSchemaFileFormatNotSupported error
func NotFoundFailure ¶
func NotFoundFailure(w http.ResponseWriter, r *http.Request)
NotFoundFailure response
func ResponseStatus ¶
func ResponseStatus(w http.ResponseWriter) int
ResponseStatus returns the HTTP response status. Remember that the status is only set by the server after WriteHeader has been called.
func ServiceUnavailableFailure ¶
func ServiceUnavailableFailure(w http.ResponseWriter, retry time.Duration)
ServiceUnavailableFailure response
Types ¶
type ErrSchemaFileFormatNotSupported ¶
type ErrSchemaFileFormatNotSupported struct {
Ext string
}
ErrSchemaFileFormatNotSupported type
func (*ErrSchemaFileFormatNotSupported) Error ¶
func (e *ErrSchemaFileFormatNotSupported) Error() string
type ErrSchemaNotFound ¶
type ErrSchemaNotFound struct {
Name string
}
ErrSchemaNotFound type
func (*ErrSchemaNotFound) Error ¶
func (e *ErrSchemaNotFound) Error() string
type ErrorMessage ¶
ErrorMessage struct
func (ErrorMessage) Error ¶
func (e ErrorMessage) Error() string
Error implements ErrorMessageInterface
func (ErrorMessage) GetCode ¶
func (e ErrorMessage) GetCode() int
GetCode implements ErrorMessageInterface
func (ErrorMessage) GetMessage ¶
func (e ErrorMessage) GetMessage() string
GetMessage implements ErrorMessageInterface
type ErrorMessageInterface ¶
ErrorMessageInterface interface
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorMessage `json:"error"`
}
ErrorResponse struct
type ErrorsResponse ¶
type ErrorsResponse struct {
Errors []error `json:"errors"`
}
ErrorsResponse struct
type HealthCheckHandler ¶
HealthCheckHandler type
type HealthCheckResponse ¶
type HealthCheckResponse struct { Status bool `json:"status"` Services map[string]bool `json:"services"` }
HealthCheckResponse struct
type Router ¶
Router struct
func (*Router) AddController ¶
func (r *Router) AddController(controller Controller)
AddController to Router
func (*Router) AddHealthCheck ¶
func (r *Router) AddHealthCheck(name string, handle HealthCheckHandler) error
AddHealthCheck handler
func (*Router) AddPrefixRoute ¶
AddPrefixRoute to Router
func (*Router) AddPrefixRouteFunc ¶
AddPrefixRouteFunc to Router
func (*Router) AddRouteFunc ¶
AddRouteFunc to Router
func (*Router) EnableCorsWithOptions ¶
EnableCorsWithOptions for all endpoint
func (*Router) SetNotFoundFunc ¶
func (r *Router) SetNotFoundFunc(handler http.HandlerFunc)
SetNotFoundFunc handler
type SchemaValidator ¶
SchemaValidator interface experimental
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator struct
func (*Validator) AddSchemFromObject ¶
func (v *Validator) AddSchemFromObject(object SchemaValidator) error
AddSchemFromObject experimental
func (*Validator) AddSchemFromObjectName ¶
func (v *Validator) AddSchemFromObjectName(name string, object SchemaValidator) error
AddSchemFromObjectName experimental
func (*Validator) AddSchemaFromFile ¶
AddSchemaFromFile name
func (*Validator) AddSchemaFromJSON ¶
func (v *Validator) AddSchemaFromJSON(name string, content json.RawMessage) error
AddSchemaFromJSON string
func (*Validator) AddSchemaFromReader ¶
AddSchemaFromReader func
func (*Validator) AddSchemaFromYAML ¶
AddSchemaFromYAML string
type ValidatorError ¶
type ValidatorError struct { Code int32 `json:"code,omitempty"` Name string `json:"name,omitempty"` In string `json:"in,omitempty"` Value interface{} `json:"value,omitempty"` Message string `json:"message"` Values []interface{} `json:"values,omitempty"` }
ValidatorError struct
func (ValidatorError) Error ¶
func (e ValidatorError) Error() string