http

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MiddlewareAdapter

func MiddlewareAdapter(m middleware.Middleware) mist.Middleware

MiddlewareAdapter 将phantasm中间件适配到mist中间件

Types

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

HTTPServer 是HTTP服务器

func NewHTTPServer

func NewHTTPServer(opts ...HTTPServerOption) (*HTTPServer, error)

NewHTTPServer 创建一个新的HTTP服务器

func (*HTTPServer) DELETE

func (s *HTTPServer) DELETE(path string, handler mist.HandleFunc)

DELETE 注册DELETE方法处理程序

func (*HTTPServer) Endpoint

func (s *HTTPServer) Endpoint() (*url.URL, error)

Endpoint 返回HTTP服务器的URL端点

func (*HTTPServer) GET

func (s *HTTPServer) GET(path string, handler mist.HandleFunc)

GET 注册GET方法处理程序

func (*HTTPServer) GetEngine added in v0.2.4

func (s *HTTPServer) GetEngine() *mist.HTTPServer

GetEngine 返回内部的mist HTTP服务器引擎

func (*HTTPServer) Group

func (s *HTTPServer) Group(prefix string) interface{}

Group 创建路由组

func (*HTTPServer) POST

func (s *HTTPServer) POST(path string, handler mist.HandleFunc)

POST 注册POST方法处理程序

func (*HTTPServer) PUT

func (s *HTTPServer) PUT(path string, handler mist.HandleFunc)

PUT 注册PUT方法处理程序

func (*HTTPServer) Start

func (s *HTTPServer) Start(ctx context.Context) error

Start 启动HTTP服务器

func (*HTTPServer) Stop

func (s *HTTPServer) Stop(ctx context.Context) error

Stop 停止HTTP服务器

func (*HTTPServer) UseMiddleware

func (s *HTTPServer) UseMiddleware(middleware ...middleware.Middleware)

UseMiddleware 在HTTP服务器上使用Phantasm中间件

type HTTPServerOption

type HTTPServerOption func(*HTTPServer)

HTTPServerOption 是HTTP服务器选项

func WithAddress

func WithAddress(addr string) HTTPServerOption

WithAddress 设置服务器地址

func WithTLS

func WithTLS(cert, key string) HTTPServerOption

WithTLS 设置TLS配置

func WithTimeout

func WithTimeout(timeout time.Duration) HTTPServerOption

WithTimeout 设置服务器超时

type Server

type Server struct {
	*mist.HTTPServer
	// contains filtered or unexported fields
}

Server 是HTTP服务器

func NewServer

func NewServer(opts ...ServerOption) *Server

NewServer 创建HTTP服务器

func (*Server) Endpoint

func (s *Server) Endpoint() (*url.URL, error)

Endpoint 返回HTTP服务器的端点

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start 启动HTTP服务器

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop 停止HTTP服务器

type ServerOption

type ServerOption func(*Server)

ServerOption 是HTTP服务器选项

func Address

func Address(address string) ServerOption

Address 设置地址,例如 ":8000", "127.0.0.1:8000" 等

func Logger

func Logger(logger log.Logger) ServerOption

Logger 设置日志记录器

func Network

func Network(network string) ServerOption

Network 设置网络类型,例如 "tcp", "tcp4", "tcp6", "unix" 或 "unixpacket"

func SetHTTPServer

func SetHTTPServer(server *mist.HTTPServer) ServerOption

SetHTTPServer 设置Mist HTTP服务器

func TLSConfig

func TLSConfig(c *tls.Config) ServerOption

TLSConfig 设置TLS配置

func Timeout

func Timeout(timeout time.Duration) ServerOption

Timeout 设置超时时间

Jump to

Keyboard shortcuts

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