Documentation ¶
Index ¶
- func NewHandler(definitions HandlersDefinition) http.Handler
- func ReadRequest(w http.ResponseWriter, r *http.Request, req interface{}) error
- func RunServer(ctx context.Context, serverURL string, httpHandler http.Handler, ...) error
- func WriteErrorResponse(w http.ResponseWriter, statusCode int, errs ...Error)
- func WriteResponse(w http.ResponseWriter, statusCode int, body []byte)
- type CORSOpt
- type Error
- type ErrorCode
- type ErrorResponseJson
- type HandlerDefinition
- type HandlersDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
func NewHandler(definitions HandlersDefinition) http.Handler
NewHandler is a constructor
func ReadRequest ¶
func ReadRequest(w http.ResponseWriter, r *http.Request, req interface{}) error
func RunServer ¶
func RunServer(ctx context.Context, serverURL string, httpHandler http.Handler, corsOpt *CORSOpt) error
RunServer execute http server
func WriteErrorResponse ¶
func WriteErrorResponse(w http.ResponseWriter, statusCode int, errs ...Error)
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, statusCode int, body []byte)
Types ¶
type CORSOpt ¶
type CORSOpt struct { AllowedOrigins []string AllowedMethods []string AllowedHeaders []string OptionsPassthrough bool }
CORSOpt is a set of CORS options
type ErrorResponseJson ¶
type ErrorResponseJson struct { // Errors corresponds to the JSON schema field "errors". Errors []Error `json:"errors,omitempty"` }
type HandlerDefinition ¶
type HandlerDefinition struct {
Endpoint, Method string
HandlerFunc http.HandlerFunc
}
HandlerDefinition used to declare endpoints and http handlers
type HandlersDefinition ¶
type HandlersDefinition []HandlerDefinition
HandlersDefinition is self-described
Click to show internal directories.
Click to hide internal directories.