Documentation
¶
Index ¶
- func CreatePageToken(arrayData interface{}, dataLimit int, fieldNameId string, fieldNameDate string) (nextToken string)
- func LookupError(lookup map[error]*structs.ErrorResponse, err error) (res *structs.ErrorResponse)
- func NewHttpHandler(c HttpHandlerContext, opts ...HandlerOption) func(...) HttpHandler
- func ParsePageToken(pageToken string) (token map[string]string)
- func PathPattern(input string) string
- type CustomWriter
- type HandlerOption
- type HttpHandler
- type HttpHandlerContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePageToken ¶ added in v2.15.3
func LookupError ¶
func LookupError(lookup map[error]*structs.ErrorResponse, err error) (res *structs.ErrorResponse)
LookupError will get error message based on error type, with variables if you want give dynamic message error
func NewHttpHandler ¶
func NewHttpHandler(c HttpHandlerContext, opts ...HandlerOption) func(handler func(w http.ResponseWriter, r *http.Request) (interface{}, *string, error)) HttpHandler
func ParsePageToken ¶ added in v2.15.3
func PathPattern ¶ added in v2.20.0
PathPattern modify params on url
Types ¶
type CustomWriter ¶
type CustomWriter struct {
C HttpHandlerContext
}
func (*CustomWriter) Write ¶
func (c *CustomWriter) Write(w http.ResponseWriter, data interface{}, nextPage *string)
func (*CustomWriter) WriteError ¶
func (c *CustomWriter) WriteError(w http.ResponseWriter, err error)
WriteError sending error response based on err type
type HandlerOption ¶ added in v2.17.0
type HandlerOption func(*HttpHandler)
func WithMetric ¶ added in v2.17.0
func WithMetric(telegrafHost string, telegrafPort int, svcName string) HandlerOption
WithMetric wire statsd client to perkakas handler
type HttpHandler ¶
type HttpHandler struct { // H is handler, with return interface{} as data object, *string for token next page, error for error type H func(w http.ResponseWriter, r *http.Request) (interface{}, *string, error) CustomWriter Metric *statsd.Client ServiceName string }
func (HttpHandler) ServeHTTP ¶
func (h HttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HttpHandlerContext ¶
type HttpHandlerContext struct { M structs.Meta E map[error]*structs.ErrorResponse }
func NewContextHandler ¶ added in v2.7.0
func NewContextHandler(meta structs.Meta) HttpHandlerContext
func (HttpHandlerContext) AddError ¶ added in v2.7.0
func (hctx HttpHandlerContext) AddError(key error, value *structs.ErrorResponse)
func (HttpHandlerContext) AddErrorMap ¶ added in v2.7.0
func (hctx HttpHandlerContext) AddErrorMap(errMap map[error]*structs.ErrorResponse)
Click to show internal directories.
Click to hide internal directories.