Documentation
¶
Index ¶
- Variables
- func GenerateSelfSignCertificate(opt SelfSign) (cert tls.Certificate, err error)
- type Block
- type Cond
- 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)
- func (s *Server) UseFunc(m MiddlewareFunc)
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 Cond ¶ added in v0.11.2
type Cond struct {
If func(r *http.Request) bool
Then Middleware
Else Middleware
}
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
func (*Middlewares) UseFunc ¶ added in v0.13.2
func (ms *Middlewares) UseFunc(m MiddlewareFunc)
type Server ¶
type Server struct {
Addr string
Handler http.Handler
ReadTimeout time.Duration
ReadHeaderTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxHeaderBytes int
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
BaseContext func(net.Listener) context.Context
// X-Forwarded-Proto header ("http"/"https") instead of allocating a fresh
// slice per request, saving one allocation on every request that sets it.
//
// UNSAFE if any middleware mutates the X-Forwarded-Proto value slice in
// place — e.g. headers.MapRequest("X-Forwarded-Proto", …) or code doing
// r.Header["X-Forwarded-Proto"][0] = …; the mutation would corrupt the
// shared slice for every subsequent request. Appending (headers.AddRequest)
// is safe. Enable it only if you control the whole middleware chain. Like
// the other fields it must be set before serving; setting it afterwards has
// no effect.
ShareProtoSlice bool
// 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
func (*Server) UseFunc ¶ added in v0.13.2
func (s *Server) UseFunc(m MiddlewareFunc)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
pkg
|
|
|
cache
Package cache is an HTTP response-cache middleware with a pluggable storage backend.
|
Package cache is an HTTP response-cache middleware with a pluggable storage backend. |
|
waf
Package waf provides a Web Application Firewall middleware for parapet.
|
Package waf provides a Web Application Firewall middleware for parapet. |