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 Failure ¶ added in v1.4.0
func Failure(w http.ResponseWriter, status int, err ErrorMessage)
Failure response
func FailureFromError ¶ added in v1.4.0
func FailureFromError(w http.ResponseWriter, status int, err error)
FailureFromError write ErrorMessage from error
func FailureFromValidator ¶ added in v1.4.0
func FailureFromValidator(w http.ResponseWriter, result *validate.Result)
FailureFromValidator response
func InternalServerFailure ¶ added in v1.4.0
func InternalServerFailure(w http.ResponseWriter, r *http.Request, p interface{})
InternalServerFailure response
func JSON ¶ added in v1.4.0
func JSON(w http.ResponseWriter, code int, body interface{})
JSON response
func MethodNotAllowedFailure ¶ added in v1.4.0
func MethodNotAllowedFailure(w http.ResponseWriter, r *http.Request)
MethodNotAllowedFailure response
func NewErrSchemaFileFormatNotSupported ¶ added in v1.4.0
NewErrSchemaFileFormatNotSupported error
func NewErrSchemaNotFound ¶ added in v1.4.0
NewErrSchemaNotFound error
func NotFoundFailure ¶ added in v1.4.0
func NotFoundFailure(w http.ResponseWriter, r *http.Request)
NotFoundFailure response
func ResponseStatus ¶ added in v1.4.0
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 ¶ added in v1.4.0
func ServiceUnavailableFailure(w http.ResponseWriter, retry time.Duration)
ServiceUnavailableFailure response
Types ¶
type ErrSchemaFileFormatNotSupported ¶ added in v1.4.0
type ErrSchemaFileFormatNotSupported struct {
Ext string
}
ErrSchemaFileFormatNotSupported type
func (*ErrSchemaFileFormatNotSupported) Error ¶ added in v1.4.0
func (e *ErrSchemaFileFormatNotSupported) Error() string
type ErrSchemaNotFound ¶ added in v1.4.0
type ErrSchemaNotFound struct {
Name string
}
ErrSchemaNotFound type
func (*ErrSchemaNotFound) Error ¶ added in v1.4.0
func (e *ErrSchemaNotFound) Error() string
type ErrorMessage ¶ added in v1.4.0
ErrorMessage struct
func (ErrorMessage) Error ¶ added in v1.4.0
func (e ErrorMessage) Error() string
Error implements ErrorMessageInterface
func (ErrorMessage) GetCode ¶ added in v1.4.0
func (e ErrorMessage) GetCode() int
GetCode implements ErrorMessageInterface
func (ErrorMessage) GetMessage ¶ added in v1.4.0
func (e ErrorMessage) GetMessage() string
GetMessage implements ErrorMessageInterface
type ErrorMessageInterface ¶ added in v1.4.0
ErrorMessageInterface interface
type ErrorResponse ¶ added in v1.4.0
type ErrorResponse struct {
Error ErrorMessage `json:"error"`
}
ErrorResponse struct
type ErrorsResponse ¶ added in v1.4.0
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
func (*Router) Use ¶ added in v1.4.0
func (r *Router) Use(middleware ...alice.Constructor)
Use middleware
type SchemaValidator ¶ added in v1.4.0
SchemaValidator interface experimental
type Validator ¶ added in v1.4.0
type Validator struct {
// contains filtered or unexported fields
}
Validator struct
func (*Validator) AddSchemFromObject ¶ added in v1.4.0
func (v *Validator) AddSchemFromObject(object SchemaValidator) error
AddSchemFromObject experimental
func (*Validator) AddSchemFromObjectName ¶ added in v1.4.0
func (v *Validator) AddSchemFromObjectName(name string, object SchemaValidator) error
AddSchemFromObjectName experimental
func (*Validator) AddSchemaFromFile ¶ added in v1.4.0
AddSchemaFromFile name
func (*Validator) AddSchemaFromJSON ¶ added in v1.4.0
func (v *Validator) AddSchemaFromJSON(name string, content json.RawMessage) error
AddSchemaFromJSON string
func (*Validator) AddSchemaFromReader ¶ added in v1.4.0
AddSchemaFromReader func
func (*Validator) AddSchemaFromYAML ¶ added in v1.4.0
AddSchemaFromYAML string
type ValidatorError ¶ added in v1.4.0
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 ¶ added in v1.4.0
func (e ValidatorError) Error() string