Documentation
¶
Index ¶
- type Middleware
- type NetworkFramework
- type RW
- type Server
- func (s *Server) Framework(framework NetworkFramework)
- func (s *Server) Handle(pattern string, handler http.Handler)
- func (s *Server) HandleFunc(pattern string, handler http.HandlerFunc)
- func (s *Server) ListenAndServe() error
- func (s *Server) ServeFiles(pattern string, root http.FileSystem)
- func (s *Server) SetTLS(active bool, certificatePath, keyPath string)
- func (s *Server) Use(middleware ...func(http.HandlerFunc) http.HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
type Middleware = func(http.HandlerFunc) http.HandlerFunc
Middleware defines a middleware parameter type for the server.
type NetworkFramework ¶
type NetworkFramework string
const ( HTTP NetworkFramework = "net/http" // Standard HTTP package NET NetworkFramework = "net" // Standard net package NETPOLL NetworkFramework = "github.com/cloudwego/netpoll" // Netpoll package, a high-performance network library (https://github.com/cloudwego/netpoll) )
func (NetworkFramework) IsValid ¶
func (nf NetworkFramework) IsValid() bool
func (NetworkFramework) String ¶
func (nf NetworkFramework) String() string
type RW ¶
type RW struct {
// contains filtered or unexported fields
}
RW is a custom ResponseWriter that implements the http.ResponseWriter interface.
func (*RW) WriteHeader ¶
type Server ¶
type Server struct {
Address string
ErrorHandler func(http.ResponseWriter, *http.Request, error)
TLS bool
// contains filtered or unexported fields
}
Server is a custom HTTP server that uses netpoll for handling connections.
func NewServer ¶
NewServer creates a new Server instance with the specified address and HTTP ServeMux.
func (*Server) Framework ¶
func (s *Server) Framework(framework NetworkFramework)
Framework sets the network framework for the server. by default it uses NETPOLL.
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(pattern string, handler http.HandlerFunc)
HandleFunc binds a handler function to a specific pattern in the server's HTTP ServeMux.
func (*Server) ListenAndServe ¶
ListenAndServe starts the server and listens for incoming connections.
func (*Server) ServeFiles ¶
func (s *Server) ServeFiles(pattern string, root http.FileSystem)
ServeFiles serves static files from the specified root directory using the given pattern.
func (*Server) Use ¶
func (s *Server) Use(middleware ...func(http.HandlerFunc) http.HandlerFunc)
Use binds middleware functions to the server.
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
cache/map
command
|
|
|
cache/redis
command
|
|
|
http
command
|
|
|
metrics/cmd
command
|
|
|
middleware
command
|
|
|
tracing/cmd
command
|
|
|
websocket
command
|
|