httplog

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONLogger

func JSONLogger(dst io.Writer, reqs <-chan *Request)

func TextLogger

func TextLogger(dst io.Writer, reqs <-chan *Request)

Types

type Request

type Request struct {
	Method  string              `json:"method"`
	Path    string              `json:"path"`
	Query   map[string][]string `json:"query,omitempty"`
	Proto   string              `json:"proto"`
	Host    string              `json:"host"`
	Headers map[string][]string `json:"headers,omitempty"`
	Body    string              `json:"body,omitempty"`
	At      time.Time           `json:"at"`
}

type Server

type Server struct {
	// ResponseCode is the HTTP Status Code sent in response to all requests,
	// if not set, HTTP 200 is used.
	ResponseCode int

	// ResponseBody is the contents sent in response to all requests, if not
	// set, no response body is used.
	ResponseBody []byte
	// contains filtered or unexported fields
}

func NewServer

func NewServer(requestBufferSize int) *Server

func (*Server) Requests

func (s *Server) Requests() <-chan *Request

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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