httpsrv

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CarryLog

func CarryLog() func(http.Handler) http.Handler

func RecordRequestID

func RecordRequestID(next http.Handler) http.Handler

func RequestLog

func RequestLog(next http.Handler) http.Handler

Types

type API

type API struct {
	Pattern string
	Method  string
	Func    http.HandlerFunc
}

type Controller

type Controller interface {
	Slug() string
	Middlewares() []Middleware
	APIs() []API
}

type HTTPServer

type HTTPServer interface {
	With(Controller)
	Serve() error
}

func NewHTTPServer

func NewHTTPServer(lc fx.Lifecycle, opt Option, logger *slog.Logger, cs ...Controller) HTTPServer

type Middleware

type Middleware struct {
	Middleware func(http.Handler) http.Handler
	Scope      MiddlewareScope
}

type MiddlewareScope

type MiddlewareScope int
const (
	ScopeController MiddlewareScope = iota // controller 层面
	ScopeGlobal                            // 全局中间件
)

type Option

type Option struct {
	Addr     string `json:"addr" yaml:"addr" toml:"addr"`
	CertFile string `json:"cert_file" toml:"cert_file" yaml:"cert_file"`
	KeyFile  string `json:"key_file" toml:"key_file" yaml:"key_file"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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