Documentation ¶
Index ¶
- Variables
- func GenerateSelfSignCertificate(opt SelfSign) (cert tls.Certificate, err error)
- type Block
- type Conditional
- type Handler
- type Middleware
- type MiddlewareFunc
- type Middlewares
- type SelfSign
- type Server
- func (s *Server) ListenAndServe() error
- func (s *Server) ModifyConnection(f func(conn net.Conn) net.Conn)
- func (s *Server) RegisterOnShutdown(f func())
- func (s *Server) Serve(l net.Listener) error
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Shutdown() error
- func (s *Server) Use(m Middleware)
Constants ¶
This section is empty.
Variables ¶
var ServerContextKey = serverContextKey{}
ServerContextKey is the context key that store *parapet.Server
Functions ¶
func GenerateSelfSignCertificate ¶ added in v0.7.2
func GenerateSelfSignCertificate(opt SelfSign) (cert tls.Certificate, err error)
GenerateSelfSignCertificate generates new self sign certificate
Types ¶
type Conditional ¶ added in v0.5.0
Conditional returns condition for given request
func TrustCIDRs ¶ added in v0.5.0
func TrustCIDRs(s []string) Conditional
TrustCIDRs trusts given CIDR list
type Handler ¶ added in v0.7.1
type Handler http.HandlerFunc
Handler wraps http handler func with parapet's middleware
type Middleware ¶
Middleware is the http middleware
type MiddlewareFunc ¶
MiddlewareFunc is the adapter type for Middleware
func (MiddlewareFunc) ServeHandler ¶
func (f MiddlewareFunc) ServeHandler(h http.Handler) http.Handler
ServeHandler calls f
type Middlewares ¶
type Middlewares []Middleware
Middlewares type
func (Middlewares) ServeHandler ¶
func (ms Middlewares) ServeHandler(h http.Handler) http.Handler
ServeHandler implements middleware interface
type Server ¶
type Server struct { Addr string Handler http.Handler ReadTimeout time.Duration ReadHeaderTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration TCPKeepAlivePeriod time.Duration GraceTimeout time.Duration WaitBeforeShutdown time.Duration ErrorLog *log.Logger TrustProxy Conditional H2C bool ReusePort bool ConnState func(conn net.Conn, state http.ConnState) TLSConfig *tls.Config // contains filtered or unexported fields }
Server is the parapet server
func New ¶
func New() *Server
New creates new middleware server default config
This server should not expose to the internet but run behind reverse proxy
func NewBackend ¶
func NewBackend() *Server
NewBackend creates new backend server default config
This server use to run behind parapet server or run behind other reverse proxy
func NewFrontend ¶
func NewFrontend() *Server
NewFrontend creates new frontend server default config
func (*Server) ListenAndServe ¶
ListenAndServe starts web server
func (*Server) ModifyConnection ¶ added in v0.6.0
ModifyConnection modifies connection before send to http
func (*Server) RegisterOnShutdown ¶ added in v0.1.2
func (s *Server) RegisterOnShutdown(f func())
RegisterOnShutdown calls f when server received SIGTERM