Version: v0.7.6 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2022 License: Apache-2.0 Imports: 13 Imported by: 0




This section is empty.


This section is empty.


func IsPrivateIP added in v0.2.11

func IsPrivateIP(address string) (bool, error)

IsPrivateIP works by checking if the address is under private CIDR blocks. List of private CIDR blocks can be seen on :

func RealIP added in v0.2.11

func RealIP(r *http.Request) string

RealIP return client's real public IP address from http request headers.


type Option

type Option func(s *Server)

func WithAccessLog added in v0.2.11

func WithAccessLog(enabled bool) Option

func WithAddr added in v0.5.9

func WithAddr(addr string) Option

func WithAddress

func WithAddress(address string) Option

func WithCORS

func WithCORS(enabled bool) Option

func WithDebug

func WithDebug(debug bool) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithMiddleware

func WithMiddleware(middleware func(http.Handler) http.Handler) Option

func WithPathPrefix

func WithPathPrefix(prefix string) Option

func WithPort

func WithPort(port int) Option

func WithShutdownTimeout added in v0.1.5

func WithShutdownTimeout(timeout time.Duration) Option

func WithStartupTimeout added in v0.1.5

func WithStartupTimeout(timeout time.Duration) Option

func WithStripQueryString added in v0.2.1

func WithStripQueryString(enabled bool) Option

type Server

type Server struct {
	App             Service
	Address         string
	Port            int
	CertFile        string
	KeyFile         string
	PathPrefix      string
	StartupTimeout  time.Duration
	ShutdownTimeout time.Duration
	Logger          *zap.Logger
	Debug           bool

Server wraps the Service with additional http and app lifecycle handling

func New

func New(app Service, options ...Option) *Server

New create new Server

func (*Server) Run

func (s *Server) Run()

func (*Server) RunContext added in v0.5.9

func (s *Server) RunContext(ctx context.Context)

type Service added in v0.2.1

type Service interface {

	// Startup controls app startup
	Startup(ctx context.Context) error

	// Shutdown controls app shutdown
	Shutdown(ctx context.Context) error

Service is a http.Handler with Startup and Shutdown lifecycle

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL