Documentation ¶
Overview ¶
Package http provides a registration interface for http services
Index ¶
- Variables
- func AddFlags(flagSet *pflag.FlagSet)
- func AddFlagsPrefix(flagSet *pflag.FlagSet, prefix string, Opt *Options)
- func Mount(pattern string, h http.Handler) error
- func Restart() error
- func Route(pattern string, fn func(r chi.Router)) (chi.Router, error)
- func Router() (chi.Router, error)
- func SetOptions(opt Options)
- func Shutdown() error
- func URL() string
- func Wait()
- type Middleware
- type Options
- type Server
Constants ¶
This section is empty.
Variables ¶
var DefaultOpt = Options{ ListenAddr: "127.0.0.1:8080", ServerReadTimeout: 1 * time.Hour, ServerWriteTimeout: 1 * time.Hour, MaxHeaderBytes: 4096, }
DefaultOpt is the default values used for Options
var Help = `` /* 1549-byte string literal not displayed */
Help contains text describing the http server to add to the command help.
Functions ¶
func AddFlagsPrefix ¶
AddFlagsPrefix adds flags for the httplib
func Restart ¶
func Restart() error
Restart or start the default http server using the default options and no handlers
func SetOptions ¶
func SetOptions(opt Options)
SetOptions thread safe setter for the default server options
Types ¶
type Middleware ¶
Middleware function signature required by chi.Router.Use()
type Options ¶
type Options struct { ListenAddr string // Port to listen on BaseURL string // prefix to strip from URLs ServerReadTimeout time.Duration // Timeout for server reading data ServerWriteTimeout time.Duration // Timeout for server writing data MaxHeaderBytes int // Maximum size of request header SslCert string // SSL PEM key (concatenation of certificate and CA certificate) SslKey string // SSL PEM Private key ClientCA string // Client certificate authority to verify clients with }
Options contains options for the http Server
func GetOptions ¶
func GetOptions() Options
GetOptions thread safe getter for the default server options
type Server ¶
type Server interface { Router() chi.Router Route(pattern string, fn func(r chi.Router)) chi.Router Mount(pattern string, h http.Handler) Shutdown() error }
Server interface of http server
func NewServer ¶
NewServer instantiates a new http server using provided listeners and options This function is provided if the default http server does not meet a services requirements and should not generally be used A http server can listen using multiple listeners. For example, a listener for port 80, and a listener for port 443. tlsListeners are ignored if opt.SslKey is not provided