web

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminAuthMiddleware

func AdminAuthMiddleware(ct CheckToken) func(http.Handler) http.Handler

AdminAuthMiddleware will return HTTP middleware that will authenticate a user is authenticated and has proper permissions.

func RatesShow

func RatesShow(store RateStore, rateInterval time.Duration) http.Handler

RatesShow gets and renders a single Rate for a given timestamp.

Types

type CheckToken

type CheckToken func(token, scope string) bool

CheckToken is a function that is used by the AdminAuthMiddleware to check a given token

type RateStore

type RateStore interface {
	Rate(int64) (store.Rate, error)
}

RateStore is the interface from which the server will get rates to be rendered via HTTP in JSON.

type Server

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

Server handles setting up an HTTP server and servicing HTTP requests.

func NewServer

func NewServer(
	port uint16,
	ct CheckToken,
	rs RateStore,
	rateInterval time.Duration,
	opts ...ServerOption,
) *Server

NewServer opens a TCP listener and returns an initialized Server.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the address that the listener is bound to.

func (*Server) Serve

func (s *Server) Serve()

Serve serves the HTTP server on the servers Listener. This is a blocking method.

func (*Server) Stop

func (s *Server) Stop()

Stop will perform a graceful shutdown of the HTTP server.

type ServerOption

type ServerOption func(*Server)

ServerOption is a function that can be passed to the server initializer to configure optional settings.

func WithLogWriter

func WithLogWriter(w io.Writer) ServerOption

WithLogWriter will override the logger used for HTTP logs.

Jump to

Keyboard shortcuts

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