package report

import "github.com/streadway/handy/report"

Package report organizes textual reporting from the HTTP context.

Index

Functions

func JSON

func JSON(writer io.Writer, next http.Handler) http.Handler

JSON writes a JSON encoded Event to the provided writer at the completion of each request

func JSONMiddleware

func JSONMiddleware(writer io.Writer) func(http.Handler) http.Handler

JSONMiddleware returns a composable handler factory implementing the JSON handler.

Types

type Event

type Event struct {
	Time           time.Time `json:"time,omitempty"`
	Method         string    `json:"method,omitempty"`
	Url            string    `json:"url,omitempty"`
	Path           string    `json:"path,omitempty"`
	Proto          string    `json:"proto,omitempty"`
	Status         int       `json:"status,omitempty"`
	Ms             int       `json:"ms"`
	Size           int64     `json:"size"`
	RemoteAddr     string    `json:"remote_addr,omitempty"`
	ForwardedFor   string    `json:"forwarded_for,omitempty"`
	ForwardedProto string    `json:"forwarded_proto,omitempty"`
	Range          string    `json:"range,omitempty"`
	Host           string    `json:"host,omitempty"`
	Referrer       string    `json:"referrer,omitempty"`
	UserAgent      string    `json:"user_agent,omitempty"`
	Authorization  string    `json:"authorization,omitempty"`
	Region         string    `json:"region,omitempty"`
	Country        string    `json:"country,omitempty"`
	City           string    `json:"city,omitempty"`
	RequestId      string    `json:"request_id,omitempty"`
}

Event contains significant fields from the request or response to report

Source Files

event.go json.go

Version
v0.0.0-20200128134331-0f66f006fb2e (latest)
Published
Jan 28, 2020
Platform
linux/amd64
Imports
5 packages
Last checked
2 months ago

Tools for package owners.