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 ¶
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 ¶
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 ¶
type HandlerOption func(*HttpHandler)
func WithMetric ¶
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 ¶
func NewContextHandler(meta structs.Meta) HttpHandlerContext
func (HttpHandlerContext) AddError ¶
func (hctx HttpHandlerContext) AddError(key error, value *structs.ErrorResponse)
func (HttpHandlerContext) AddErrorMap ¶
func (hctx HttpHandlerContext) AddErrorMap(errMap map[error]*structs.ErrorResponse)
Click to show internal directories.
Click to hide internal directories.