server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface{}

type Middle

type Middle router.Middle[*http2.Stream[Conn]]

type Server

type Server[T any] struct {
	Name string
	// Host 服务Host
	Addr string
	// TLS FILE
	CertFile string
	// TLS KEY
	KeyFile string
	// TLS
	TLSConfig *tls.Config

	OnOpen    func(stream *http2.Stream[Conn])
	OnMessage func(stream *http2.Stream[Conn])
	OnClose   func(stream *http2.Stream[Conn])
	OnError   func(stream *http2.Stream[Conn], err error)
	OnSuccess func()

	ReadTimeout       time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	ReadHeaderTimeout time.Duration
	MaxHeaderBytes    int
	// contains filtered or unexported fields
}

func (*Server[T]) GetRouter

func (s *Server[T]) GetRouter() *router.Router[*http2.Stream[Conn], T]

func (*Server[T]) LocalAddr

func (s *Server[T]) LocalAddr() net.Addr

func (*Server[T]) Ready

func (s *Server[T]) Ready()

func (*Server[T]) ServeHTTP

func (s *Server[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server[T]) SetRouter

func (s *Server[T]) SetRouter(router *router.Router[*http2.Stream[Conn], T]) *Server[T]

func (*Server[T]) SetStaticRouter

func (s *Server[T]) SetStaticRouter(router *StaticRouter) *Server[T]

func (*Server[T]) Shutdown

func (s *Server[T]) Shutdown() error

func (*Server[T]) Start

func (s *Server[T]) Start()

Start Http

func (*Server[T]) Use

func (s *Server[T]) Use(middle ...func(next Middle) Middle)

type Static

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

type StaticDirMiddle

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

func (*StaticDirMiddle) Handler

func (s *StaticDirMiddle) Handler(fn func(w http.ResponseWriter, r *http.Request, f http.File, i fs.FileInfo) error)

type StaticFileMiddle

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

func (*StaticFileMiddle) Handler

func (s *StaticFileMiddle) Handler(fn func(w http.ResponseWriter, r *http.Request, f http.File, i fs.FileInfo) error)

type StaticRouter

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

func (*StaticRouter) IsAllowMethod

func (r *StaticRouter) IsAllowMethod(method string) bool

func (*StaticRouter) SetAllowMethod

func (r *StaticRouter) SetAllowMethod(methods ...string)

func (*StaticRouter) SetDefaultIndex

func (r *StaticRouter) SetDefaultIndex(index ...string)

func (*StaticRouter) SetOpenDir

func (r *StaticRouter) SetOpenDir(dirIndex ...int)

func (*StaticRouter) SetStaticDirMiddle

func (r *StaticRouter) SetStaticDirMiddle(t ...string) *StaticDirMiddle

func (*StaticRouter) SetStaticDownload

func (r *StaticRouter) SetStaticDownload(flag bool)

func (*StaticRouter) SetStaticFileMiddle

func (r *StaticRouter) SetStaticFileMiddle(t ...string) *StaticFileMiddle

func (*StaticRouter) SetStaticGlobalDirMiddle

func (r *StaticRouter) SetStaticGlobalDirMiddle(fn func(w http.ResponseWriter, r *http.Request, f http.File, i fs.FileInfo) error)

func (*StaticRouter) SetStaticGlobalFileMiddle

func (r *StaticRouter) SetStaticGlobalFileMiddle(fn func(w http.ResponseWriter, r *http.Request, f http.File, i fs.FileInfo) error)

func (*StaticRouter) SetStaticPath

func (r *StaticRouter) SetStaticPath(prefixPath string, fixPath string, fileSystem http.FileSystem) int

Jump to

Keyboard shortcuts

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