server

package
v1.0.0-rc6 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseResponse

type BaseResponse struct {
	Status string `json:"status"`
	Code   string `json:"code"`
	Data   any    `json:"data"`
}

type Cors

type Cors struct {
	Origin  string
	Methods string
	Headers string
}

type ErrorResponse

type ErrorResponse map[error]int

type ReqCtx

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

type ReqHandler

type ReqHandler func(ReqCtx)

type Response

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

type ResponseConfig

type ResponseConfig struct {
	Success SuccessResponse
	Err     ErrorResponse
}

type Server

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

func New

func New() Server

type SuccessResponse

type SuccessResponse struct {
	Status int
	Code   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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