httpd

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Engine

func Engine(debug bool) *gin.Engine

func Group

func Group(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup

func NewWriter

func NewWriter(w http.ResponseWriter) (io.Writer, error)

NewWriter 初始化 SSE 响应头并返回按 data 事件写入的 writer。

func NoRoute

func NoRoute(handlers ...gin.HandlerFunc) *gin.Engine

func Recovery

func Recovery() gin.HandlerFunc

Recovery Gin panic 恢复中间件

func Server

func Server(addr string, options ...Option)

func Static

func Static(root, prefix string)

Static 静态文件服务

func StaticEmbed

func StaticEmbed(efs embed.FS, prefix, subdir string)

StaticEmbed 嵌入式静态文件服务

func StaticIndex

func StaticIndex(root, prefix string)

StaticIndex 静态文件服务(带目录列表)

func StaticServe

func StaticServe(hfs http.FileSystem, prefix string) gin.HandlerFunc

StaticServe 静态文件服务处理器

func Use

func Use(middleware ...gin.HandlerFunc) gin.IRoutes

Types

type Config

type Config struct {
	Debug        bool
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

type Option

type Option func(*Config)

func WithDebug

func WithDebug(debug bool) Option

func WithReadTimeout

func WithReadTimeout(d time.Duration) Option

func WithWriteTimeout

func WithWriteTimeout(d time.Duration) Option

type Writer

type Writer interface {
	io.Writer
	WriteEvent(event, data string) error
}

NewErrorWriter 与 NewWriter 相同,但额外支持按 event 类型写入。

func NewEventWriter

func NewEventWriter(w http.ResponseWriter) (Writer, error)

NewEventWriter 返回支持 WriteEvent 的扩展 writer。

Source Files

  • engine.go
  • recovery.go
  • server.go
  • sse.go
  • static.go

Jump to

Keyboard shortcuts

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