access

package
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package access provides an access logging handler for the ozzo routing package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(log LogFunc) routing.Handler

Logger returns a handler that logs a message for every request. The access log messages contain information including client IPs, time used to serve each request, request line, response status and size.

import (
    "log"
    "github.com/go-ozzo/ozzo-routing"
    "github.com/go-ozzo/ozzo-routing/access"
)

r := routing.New()
r.Use(access.Logger(log.Printf))

Types

type LogFunc

type LogFunc func(format string, a ...interface{})

LogFunc logs a message using the given format and optional arguments. The usage of format and arguments is similar to that for fmt.Printf(). LogFunc should be thread safe.

type LogResponseWriter

type LogResponseWriter struct {
	http.ResponseWriter
	Status       int
	BytesWritten int64
}

LogResponseWriter wraps http.ResponseWriter in order to capture HTTP status and response length information.

func (*LogResponseWriter) Write

func (r *LogResponseWriter) Write(p []byte) (int, error)

func (*LogResponseWriter) WriteHeader

func (r *LogResponseWriter) WriteHeader(status int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL