Versions in this module Expand all Collapse all v1 v1.0.6 Sep 16, 2023 v1.0.2 Aug 3, 2022 v1.0.1 Aug 3, 2022 v1.0.0 Dec 2, 2015 Changes in this version + const CombinedLogFormat + const CommonLogFormat + const DefaultLogFormat + var DefaultCommonStack = []Middleware + var DefaultDevStack = []Middleware + var DefaultProdStack = []Middleware + var ErrJSONPayloadEmpty = errors.New("JSON payload is empty") + func EnvFromContext(ctx context.Context) map[string]interface + func Error(w ResponseWriter, error string, code int) + func NewResponseWriterForTest(w http.ResponseWriter) *responseWriter + func NotFound(w ResponseWriter, r *Request) + func PathParamFromContext(ctx context.Context) map[string]string + type API struct + func NewAPI() *API + func (api *API) MakeHandler() http.Handler + func (api *API) SetApp(app App) + func (api *API) Use(middlewares ...Middleware) + type AccessLogApacheMiddleware struct + Format AccessLogFormat + Logger *log.Logger + func (mw *AccessLogApacheMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type AccessLogFormat string + type AccessLogJSONMiddleware struct + Logger *log.Logger + func (mw *AccessLogJSONMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type AccessLogJSONRecord struct + HTTPMethod string + RemoteUser string + RequestURI string + ResponseTime *time.Duration + StatusCode int + Timestamp *time.Time + UserAgent string + type App interface + AppFunc func() HandlerFunc + func MakeRouter(routes ...*Route) (App, error) + type AppSimple HandlerFunc + func (as AppSimple) AppFunc() HandlerFunc + type AuthBasicMiddleware struct + Authenticator func(userId string, password string) bool + Authorizator func(userId string, request *Request) bool + Realm string + func (mw *AuthBasicMiddleware) MiddlewareFunc(handler HandlerFunc) HandlerFunc + type CloseMiddleware struct + func (mw *CloseMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type ContentTypeCheckerMiddleware struct + func (mw *ContentTypeCheckerMiddleware) MiddlewareFunc(handler HandlerFunc) HandlerFunc + type CorsInfo struct + AccessControlRequestHeaders []string + AccessControlRequestMethod string + IsCors bool + IsPreflight bool + Origin string + OriginURL *url.URL + type CorsMiddleware struct + AccessControlAllowCredentials bool + AccessControlExposeHeaders []string + AccessControlMaxAge int + AllowedHeaders []string + AllowedMethods []string + OriginValidator func(origin string, request *Request) bool + RejectNonCorsRequests bool + func (mw *CorsMiddleware) MiddlewareFunc(handler HandlerFunc) HandlerFunc + type GzipMiddleware struct + func (mw *GzipMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type HandlerFunc func(context.Context, ResponseWriter, *Request) + func WrapMiddlewares(middlewares []Middleware, handler HandlerFunc) HandlerFunc + type IfMiddleware struct + Condition func(r *Request) bool + IfFalse Middleware + IfTrue Middleware + func (mw *IfMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type JSONIndentMiddleware struct + Indent string + Prefix string + func (mw *JSONIndentMiddleware) MiddlewareFunc(handler HandlerFunc) HandlerFunc + type JSONpMiddleware struct + CallbackNameKey string + func (mw *JSONpMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type LimiterMiddleware struct + func Limiter(limiter *config.Limiter) *LimiterMiddleware + func SimpleLimiter(max int64, ttl time.Duration) *LimiterMiddleware + func (mw *LimiterMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type Middleware interface + MiddlewareFunc func(handler HandlerFunc) HandlerFunc + type MiddlewareSimple func(handler HandlerFunc) HandlerFunc + func (ms MiddlewareSimple) MiddlewareFunc(handler HandlerFunc) HandlerFunc + type PoweredByMiddleware struct + XPoweredBy string + func (mw *PoweredByMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type RecorderMiddleware struct + func (mw *RecorderMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type RecoverMiddleware struct + EnableLogAsJSON bool + EnableResponseStackTrace bool + Logger *log.Logger + func (mw *RecoverMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type Request struct + func (r *Request) BaseURL() *url.URL + func (r *Request) DecodeJSONPayload(v interface{}) error + func (r *Request) GetCorsInfo() *CorsInfo + func (r *Request) URLFor(path string, queryParams map[string][]string) *url.URL + type ResourceHandler struct + DisableJSONIndent bool + DisableLogger bool + DisableXPoweredBy bool + EnableGzip bool + EnableLogAsJSON bool + EnableRelaxedContentType bool + EnableResponseStackTrace bool + EnableStatusService bool + ErrorLogger *log.Logger + Logger *log.Logger + LoggerFormat AccessLogFormat + OuterMiddlewares []Middleware + PreRoutingMiddlewares []Middleware + XPoweredBy string + func (rh *ResourceHandler) GetStatus() *Status + func (rh *ResourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (rh *ResourceHandler) SetRoutes(routes ...*Route) error + type ResponseWriter interface + EncodeJSON func(v interface{}) ([]byte, error) + Header func() http.Header + Write func([]byte) (int, error) + WriteHeader func(int) + WriteJSON func(v interface{}) error + type Route struct + Func HandlerFunc + HTTPMethod string + PathExp string + func Delete(pathExp string, handlerFunc HandlerFunc) *Route + func Get(pathExp string, handlerFunc HandlerFunc) *Route + func Head(pathExp string, handlerFunc HandlerFunc) *Route + func Options(pathExp string, handlerFunc HandlerFunc) *Route + func Patch(pathExp string, handlerFunc HandlerFunc) *Route + func Post(pathExp string, handlerFunc HandlerFunc) *Route + func Put(pathExp string, handlerFunc HandlerFunc) *Route + func (route *Route) MakePath(pathParams map[string]string) string + type Status struct + AverageResponseTime string + AverageResponseTimeSec float64 + Pid int + StatusCodeCount map[string]int + Time string + TimeUnix int64 + TotalCount int + TotalResponseTime string + TotalResponseTimeSec float64 + UpTime string + UpTimeSec float64 + type StatusMiddleware struct + func (mw *StatusMiddleware) GetStatus() *Status + func (mw *StatusMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type TimeoutMiddleware struct + func Timeout(timeout time.Duration) *TimeoutMiddleware + func (mw *TimeoutMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc + type TimerMiddleware struct + func (mw *TimerMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc