server

package
v1.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 21 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cors

type Cors struct {
	Origin  string
	Methods string
	Headers string
}

type ReqCtx

type ReqCtx interface {
	Request() *fasthttp.Request
	ReadJson(data any) error
	Body() []byte
	SetUserValue(key any, value any)
	UserValue(key any) any
	Telemetry() context.Context
	SetContentType(contentType string)
	SetStatusCode(statusCode int)
	Error(msg string, statusCode int)
	Write(p []byte) (int, error)
	WriteString(s string) (int, error)
	WriteJson(data any) error
	WriteResponse(response *Response) error
	NewResponse(statusCode int, status, code string, data any) *Response
}

type ReqHandler

type ReqHandler func(ReqCtx)

type Response

type Response struct {
	StatusCode int
	Status     string
	Code       string
	Data       any
}

type Server

type Server interface {
	SetServerName(name string) Server
	AddRoute(method, path string, handler func(request ReqCtx), middlewares ...func(handler ReqHandler) ReqHandler) Server
	UseState(state state.State) Server
	UseCors(cors Cors) Server
	UseLogger(logger logger.Logger) Server
	UseTelemetry(telemetry telemetry.Telemetry) Server
	UseSwagger() Server
	UseProfiling() Server
	SetListener(listener net.Listener)
	GetListener() net.Listener
	Listen(service, hostname string, port int) <-chan error
	ListenTLS(service, hostname string, port int, certFile, keyFile string) <-chan error
	Serve(service, hostname string, port int, exit chan error) <-chan error
	ServeTLS(service, hostname string, port int, exit chan error, certFile, keyFile string) <-chan error
	Shutdown() error
}

func New

func New() Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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