Documentation
¶
Index ¶
- func AllowCORS(opts *CORSOptions) func(next http.Handler) http.Handler
- func DumpHttp(level slog.Level) func(http.Handler) http.Handler
- func MiddlewareSequencer(baseHandler http.Handler, mws ...func(http.Handler) http.Handler) http.Handler
- func PanicCatcher(next http.Handler) http.Handler
- func Timer(level slog.Level) func(http.Handler) http.Handler
- func Tracer(next http.Handler) http.Handler
- type CORSOptions
- type Controller
- type Formatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowCORS ¶ added in v0.1.0
func AllowCORS(opts *CORSOptions) func(next http.Handler) http.Handler
AllowCORS sets headers for CORS mechanism supports secure.
func MiddlewareSequencer ¶
func MiddlewareSequencer(baseHandler http.Handler, mws ...func(http.Handler) http.Handler) http.Handler
MiddlewareSequencer chains middleware functions in a chain.
func PanicCatcher ¶
PanicCatcher handles panics in http.HandlerFunc.
Types ¶
type CORSOptions ¶ added in v0.1.0
type CORSOptions struct {
AllowOrigins []string // List of origins that the server allows.
AllowMethods []string // List of methods that the server allows.
AllowHeaders []string // List of headers that the server allows.
MaxAge int // Tells the browser how long (in seconds) to cache the response to the preflight request.
AllowCredentials bool // Allow browsers to expose the response to the external JavaScript code.
}
CORSOptions represents a functional option for configuring the CORS middleware.
type Controller ¶
type Controller struct {
Server *http.Server
GracefulTimeout time.Duration
// contains filtered or unexported fields
}
Controller is a wrapper around *http.Server to control the server.
Server — *http.Server, which will be managed. GracefulTimeout — time that is given to the server to shut down gracefully.
func (*Controller) Restart ¶
func (c *Controller) Restart()
Restart restarts the server if necessary. For changes to the following parameters to take effect:
Addr; TLSConfig; TLSNextProto; ConnState; BaseContext; ConnContext,
a server restart is required. Other parameters can be changed without restarting the server. If the server is not running, the function will be skipped.
func (*Controller) Shutdown ¶
func (c *Controller) Shutdown()
Shutdown gracefully shuts down the server.
func (*Controller) Start ¶
func (c *Controller) Start() (err error)
Start starts the *http.Server. If *tls.Config on the server is non nil, the server listens and serves using tls.