Documentation ¶
Index ¶
- Constants
- func AccessLogger(handler http.Handler, e bool) http.HandlerFunc
- func CORS(h http.Handler) http.Handler
- func Recovery(h http.Handler) http.Handler
- func RegisterRoutes() *httprouter.Router
- func SimpleMiddleware(h http.Handler) http.Handler
- func Start(c Config) error
- type Config
- type LogRequest
- type Pidfile
Constants ¶
const (
// CommonFormatPattern is the Apache Common Log format.
CommonFormatPattern = "%s - %s [%s] \"%s\" %d %d\n"
)
Variables ¶
This section is empty.
Functions ¶
func AccessLogger ¶
func AccessLogger(handler http.Handler, e bool) http.HandlerFunc
AccessLogger configures a HTTP access log for a web server. Using this middleware uses the Apache common logger as the default log entry.
func Recovery ¶
Recovery function handles the logging of panics if the web server encounters a error. Once the error is logged, the server will respond with a 500 error code to the client.
func RegisterRoutes ¶
func RegisterRoutes() *httprouter.Router
RegisterRoutes sets all the configured routes for the server to the designated handler and middleware.
func SimpleMiddleware ¶
SimpleMiddleware is just an example logging middleware.
Types ¶
type Config ¶
type Config struct { LogLvl string Access bool Port string PID string TLS bool Cert string Key string }
Config struct provides configuration fields for the server.
type LogRequest ¶
type LogRequest struct { http.ResponseWriter Time time.Time RemoteIP, Method, URI, Protocol, Username, Host string Status int ResponseBytes int ElapsedTime time.Duration RequestHeader http.Header }
LogRequest describes a request that is made into the server.
func (*LogRequest) Write ¶
func (w *LogRequest) Write(b []byte) (int, error)
Write writes a header in wireformat, this function is overridden so that AccessLogger can log the HTTP status.
func (*LogRequest) WriteHeader ¶
func (w *LogRequest) WriteHeader(status int)
WriteHeader overrides the default WriteHeader function so that you can log HTTP statues.