Documentation
¶
Index ¶
- func IsPrivateIP(address string) (bool, error)
- func RealIP(r *http.Request) string
- type Metrics
- type Option
- func WithAccessLog(enabled bool) Option
- func WithAddr(addr string) Option
- func WithAddress(address string) Option
- func WithCORS(enabled bool) Option
- func WithDebug(debug bool) Option
- func WithLogger(logger *zap.Logger) Option
- func WithMetrics(metrics Metrics) Option
- func WithMiddleware(middleware func(http.Handler) http.Handler) Option
- func WithPathPrefix(prefix string) Option
- func WithPort(port int) Option
- func WithSentry(dsn string) Option
- func WithShutdownTimeout(timeout time.Duration) Option
- func WithStartupTimeout(timeout time.Duration) Option
- func WithStripQueryString(enabled bool) Option
- type Server
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPrivateIP ¶ added in v0.2.11
IsPrivateIP works by checking if the address is under private CIDR blocks. List of private CIDR blocks can be seen on :
Types ¶
type Metrics ¶ added in v1.4.0
type Metrics interface {
// Handle HTTP middleware metrics handler
Handle(next http.Handler) http.Handler
// Startup controls metrics startup
Startup(ctx context.Context) error
// Shutdown controls metrics shutdown
Shutdown(ctx context.Context) error
}
Metrics represents metrics Startup and Shutdown lifecycle and Handle middleware
type Option ¶
type Option func(s *Server)
Option Server option
func WithAccessLog ¶ added in v0.2.11
WithAccessLog with server access log option
func WithMetrics ¶ added in v1.4.0
WithMetrics with server metrics option
func WithMiddleware ¶
WithMiddleware with HTTP middleware option
func WithPathPrefix ¶
WithPathPrefix with path prefix option
func WithShutdownTimeout ¶ added in v0.1.5
WithShutdownTimeout with server shutdown timeout option
func WithStartupTimeout ¶ added in v0.1.5
WithStartupTimeout with server startup timeout option
func WithStripQueryString ¶ added in v0.2.1
WithStripQueryString with strip query string option
type Server ¶
type Server struct {
http.Server
App Service
Address string
Port int
CertFile string
KeyFile string
PathPrefix string
SentryDsn string
StartupTimeout time.Duration
ShutdownTimeout time.Duration
Logger *zap.Logger
Debug bool
Metrics Metrics
}
Server wraps the Service with additional http and app lifecycle handling
func (*Server) RunContext ¶ added in v0.5.9
RunContext run server with context