middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORS

func CORS() func(inner http.Handler) http.Handler

func Logging

func Logging(logger logger) func(inner http.Handler) http.Handler

Logging is a middleware which logs response status and time in microseconds along with other data.

func Tracer

func Tracer(inner http.Handler) http.Handler

Types

type RequestLog

type RequestLog struct {
	ID           string `json:"id,omitempty"`
	StartTime    string `json:"start_time,omitempty"`
	ResponseTime int64  `json:"response_time,omitempty"`
	Method       string `json:"method,omitempty"`
	UserAgent    string `json:"user_agent,omitempty"`
	IP           string `json:"ip,omitempty"`
	URI          string `json:"uri,omitempty"`
	Response     int    `json:"response,omitempty"`
}

type StatusResponseWriter

type StatusResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

StatusResponseWriter Defines own Response Writer to be used for logging of status - as http.ResponseWriter does not let us read status.

func (*StatusResponseWriter) WriteHeader

func (w *StatusResponseWriter) WriteHeader(status int)

Jump to

Keyboard shortcuts

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