server

package
v0.0.0-...-d6c7723 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configurator

type Configurator func(o *Options)

func WithDatabase

func WithDatabase(db *sql.DB) Configurator

WithDatabase is a configurator that injects the given database instance into the final configuration.

func WithLogger

func WithLogger(logger zerolog.Logger) Configurator

WithLogger is a configurator that injects the given Logger into the final configuration.

type Options

type Options struct {
	Logger      zerolog.Logger
	DB          *sql.DB
	ValidTokens []string
}

Options is a collection of settings exposed to configure a Server at generation time.

type Server

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

Server implements a http.Hander and provides all the functionality required for creating new short links.

func New

func New(configurators ...Configurator) *Server

New creates a new Server instance after applying all provided configurators.

func (*Server) ServeHTTP

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

ServeHTTP provided to implement the http.Handler interface.

Jump to

Keyboard shortcuts

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