alkasir: github.com/alkasir/alkasir/pkg/shared/middlewares Index | Files | Directories

package middlewares

import "github.com/alkasir/alkasir/pkg/shared/middlewares"

Index

Package Files

log.go log_addons.go

Constants

const (
    // Common Log Format (CLF).
    CommonLogFormat = "%h %l %u %t \"%r\" %s %b"

    // NCSA extended/combined log format.
    CombinedLogFormat = "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\""

    // Default format, colored output and response time, convenient for development.
    DefaultLogFormat = "%t %S\033[0m \033[36;1m%Dμs\033[0m \"%r\" \033[1;30m%u \"%{User-Agent}i\"\033[0m"
)

type AccessLogApacheErrorMiddleware Uses

type AccessLogApacheErrorMiddleware struct {
    *AccessLogApacheMiddleware
}

func (*AccessLogApacheErrorMiddleware) MiddlewareFunc Uses

func (mw *AccessLogApacheErrorMiddleware) MiddlewareFunc(h rest.HandlerFunc) rest.HandlerFunc

MiddlewareFunc only logs http response codes > 200

type AccessLogApacheMiddleware Uses

type AccessLogApacheMiddleware struct {

    // Format defines the format of the access log record. See AccessLogFormat for the details.
    // It defaults to DefaultLogFormat.
    Format AccessLogFormat
    // contains filtered or unexported fields
}

AccessLogApacheMiddleware produces the access log following a format inspired by Apache mod_log_config. It depends on TimerMiddleware and RecorderMiddleware that should be in the wrapped middlewares. It also uses request.Env["REMOTE_USER"].(string) set by the auth middlewares.

func (*AccessLogApacheMiddleware) MiddlewareFunc Uses

func (mw *AccessLogApacheMiddleware) MiddlewareFunc(h rest.HandlerFunc) rest.HandlerFunc

MiddlewareFunc makes AccessLogApacheMiddleware implement the Middleware interface.

type AccessLogFormat Uses

type AccessLogFormat string

AccessLogFormat defines the format of the access log record. This implementation is a subset of Apache mod_log_config. (See http://httpd.apache.org/docs/2.0/mod/mod_log_config.html)

%b content length in bytes, - if 0
%B content length in bytes
%D response elapsed time in microseconds
%h remote address
%H server protocol
%l identd logname, not supported, -
%m http method
%P process id
%q query string
%r first line of the request
%s status code
%S status code preceeded by a terminal color
%t time of the request
%T response elapsed time in seconds, 3 decimals
%u remote user, - if missing
%{User-Agent}i user agent, - if missing
%{Referer}i referer, - is missing

Some predefined formats are provided as contants.

Directories

PathSynopsis
prometheusMW

Package middlewares imports 8 packages (graph) and is imported by 2 packages. Updated 2016-07-24. Refresh now. Tools for package owners.