rest

package
v0.0.0-...-e48602c Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opt

type Opt func(s *serverBuilder) error

Opt is an option for configuring the rest server

func HTTPPort

func HTTPPort(port int) Opt

HTTPPort configures the port the http redirect is served over

func HTTPSPort

func HTTPSPort(port int) Opt

HTTPSPort configures the port the https server serves on

func Handler

func Handler(handler http.Handler) Opt

Handler configures the rest handler that will route and respond to requests

func TLSCertPath

func TLSCertPath(path string) Opt

TLSCertPath configures the path to the tls certificate

func TLSKeyPath

func TLSKeyPath(path string) Opt

TLSKeyPath configures the path to the tls private key

type Server

type Server struct {
	*life.Life
	// contains filtered or unexported fields
}

Server is a wrapper around the http server that manages signals Note that I don't use life' lifecycle here because we have a blocking call for run (so I don't use life.Close or life.Done for managing the background thread. I use the server.ListenAndServe and server.Shutdown).

func NewServer

func NewServer(opts ...Opt) (s *Server, err error)

NewServer creates a new http server with a router. The reason why we pass through is because we are using a functional constructor and we don't want to pollute the main struct with intermediate config state

func (Server) Close

func (s Server) Close() error

Close closes the server down gracefully

Jump to

Keyboard shortcuts

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