rest

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RouteGroup

type RouteGroup interface {
	// Group 创建一个嵌套的路由组
	Group(relativePath string, handlers ...any) RouteGroup

	// Use 为路由组添加中间件
	Use(middleware ...any) RouteGroup

	// Handle 在路由组中注册一个新路由
	Handle(httpMethod, relativePath string, handlers ...any) RouteGroup

	// GET 注册一个GET请求处理器
	GET(relativePath string, handlers ...any) RouteGroup

	// POST 注册一个POST请求处理器
	POST(relativePath string, handlers ...any) RouteGroup

	// PUT 注册一个PUT请求处理器
	PUT(relativePath string, handlers ...any) RouteGroup

	// DELETE 注册一个DELETE请求处理器
	DELETE(relativePath string, handlers ...any) RouteGroup

	// PATCH 注册一个PATCH请求处理器
	PATCH(relativePath string, handlers ...any) RouteGroup

	// HEAD 注册一个HEAD请求处理器
	HEAD(relativePath string, handlers ...any) RouteGroup

	// OPTIONS 注册一个OPTIONS请求处理器
	OPTIONS(relativePath string, handlers ...any) RouteGroup
}

RouteGroup 定义了路由组的接口

type Server

type Server interface {
	// Start 启动服务器
	Start(ctx context.Context) error

	// Stop 停止服务器
	Stop(ctx context.Context) error

	// Group 创建一个新的路由组
	Group(relativePath string, handlers ...any) RouteGroup

	// Use 添加中间件
	Use(middleware ...any) Server

	// Handle 注册一个新路由
	Handle(httpMethod, relativePath string, handlers ...any) Server
}

Server 定义了REST服务器的基本接口

func NewServer

func NewServer(method string, opts ...ServerOptions) Server

NewServer 创建一个新的REST服务器实例

type ServerOptions

type ServerOptions any

ServerOptions 定义了创建服务器的选项

Directories

Path Synopsis
internal/auth
Basic Auth middleware
Basic Auth middleware
internal/pprof
this is a copy of https://github.com/gofiber/fiber/blob/main/middleware/pprof/config.go
this is a copy of https://github.com/gofiber/fiber/blob/main/middleware/pprof/config.go
internal/auth
Basic Auth middleware
Basic Auth middleware
internal/pprof
this is a copy of "https://github.com/gin-contrib/pprof/blob/master/pprof.go
this is a copy of "https://github.com/gin-contrib/pprof/blob/master/pprof.go

Jump to

Keyboard shortcuts

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