server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRegister = "default"

DefaultRegister holds the name of the default register

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(develop bool, level zerolog.Level) *zerolog.Logger

NewLogger instantiates a new global logger

Types

type ClipdController

type ClipdController struct {
	// contains filtered or unexported fields
}

ClipdController contains the handler for the "/clipd" routes

func NewClipdController

func NewClipdController(l *zerolog.Logger, c *cache.Cache) *ClipdController

NewClipdController instantiates a new clipdController

func (*ClipdController) Paste

Paste GET /clipd

func (*ClipdController) Yank

Yank POST /clipd

type ClipdServer

type ClipdServer struct {
	Logger *zerolog.Logger
	Cache  *cache.Cache
	Server *http.Server
}

ClipdServer holds the clipd server

func NewClipdServer

func NewClipdServer(config *Config) *ClipdServer

NewClipdServer creates a new Server from Config, and initializes the global logger

func (*ClipdServer) CleanAfterShutdown

func (c *ClipdServer) CleanAfterShutdown()

CleanAfterShutdown can be called after http.Server.Shutdown

func (*ClipdServer) ListenAndServe

func (c *ClipdServer) ListenAndServe() error

ListenAndServe starts the clipd server on the configured address

type Config

type Config struct {
	Addr     string
	Develop  bool
	LogLevel zerolog.Level
}

Config holds the configuration for the clipd Server

type LogEntry

type LogEntry struct {
	Method    string    `json:"method"`
	Path      string    `json:"path"`
	StartTime time.Time `json:"receivedTime"`
	Latency   int64     `json:"latencyMs"`
	Status    int       `json:"statusCode"`
}

LogEntry holds the information written to the logger

type RequestLogger

type RequestLogger struct {
	Next   http.Handler
	Logger *zerolog.Logger
}

RequestLogger is a middleware that logs incoming requests.

func (RequestLogger) ServeHTTP

func (rl RequestLogger) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ResponseStats

type ResponseStats struct {
	// contains filtered or unexported fields
}

ResponseStats is a wrapper around http.ResponseWriter to hold information for logging

func (*ResponseStats) Header

func (r *ResponseStats) Header() http.Header

Header implements http.ResponseWriter.Header

func (*ResponseStats) Write

func (r *ResponseStats) Write(b []byte) (int, error)

Write implements http.ResponseWriter.Write

func (*ResponseStats) WriteHeader

func (r *ResponseStats) WriteHeader(statusCode int)

WriteHeader implements http.ResponseWriter.WriteHeader

Jump to

Keyboard shortcuts

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