servers

package
v0.0.0-...-70a5fc5 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReadTimeout     = 3 * time.Second
	DefaultWriteTimeout    = 3 * time.Second
	DefaultServerHeader    = "Fiber"
	DefaultBodyLimit       = 4 * 1024 * 1024 // 4 MB
	DefaultPort            = "8080"
	DefaultAllowedOrigins  = "*"
	DefaultShutdownTimeout = 5 * time.Second
	DefaultSwaggerUIPath   = "/api/swagger/*"
	DefaultHost            = "localhost"
)

Variables

This section is empty.

Functions

func InjectTokenSwaggerUI

func InjectTokenSwaggerUI(t string)

func WithConfig

func WithConfig(cfg *HttpServerConfig) func(*HttpServerConfig)

Types

type ElasticAPM

type ElasticAPM struct {
	Enabled bool `mapstructure:"enabled"`
}

type Etag

type Etag struct {
	Enabled bool `mapstructure:"enabled"`
}

type Features

type Features struct {
	RequestID   RequestID   `mapstructure:"request_id"`
	Proxy       Proxy       `mapstructure:"proxy"`
	RateLimit   RateLimit   `mapstructure:"rate_limit"`
	HealthCheck HealthCheck `mapstructure:"health_check"`
	Etag        Etag        `mapstructure:"etag"`
	ElasticAPM  ElasticAPM  `mapstructure:"elastic_apm"`
	SwaggerUI   SwaggerUI   `mapstructure:"swagger_ui"`
}

type HealthCheck

type HealthCheck struct {
	Enabled bool `mapstructure:"enabled"`
}

type HttpServer

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

func NewHttpServer

func NewHttpServer(options ...func(*HttpServerConfig)) (*HttpServer, error)

func (*HttpServer) GetApp

func (s *HttpServer) GetApp() *fiber.App

func (*HttpServer) Register

func (s *HttpServer) Register(method, path string, handler core.HandlerFunc, reqFactory func() any)

func (*HttpServer) Run

func (s *HttpServer) Run() error

func (*HttpServer) Shutdown

func (s *HttpServer) Shutdown(ctx context.Context) error

Shutdown, artık Server nesnesinin bir metodudur ve global değişkene ihtiyaç duymaz.

type HttpServerConfig

type HttpServerConfig struct {
	ReadTimeout    string `mapstructure:"read_timeout"`
	WriteTimeout   string `mapstructure:"write_timeout"`
	ServerHeader   string `mapstructure:"server_header"`
	BodyLimit      int    `mapstructure:"body_limit"`
	ErrorHandler   fiber.ErrorHandler
	Port           string   `mapstructure:"port"`
	Host           string   `mapstructure:"host"`
	AllowedOrigins string   `mapstructure:"allowed_origins"`
	Features       Features `mapstructure:"features"`
}

type Proxy

type Proxy struct {
	Enabled        bool     `mapstructure:"enabled"`
	ProxyHeader    string   `mapstructure:"proxy_header"`
	TrustedProxies []string `mapstructure:"trusted_proxies"`
}

type RateLimit

type RateLimit struct {
	Enabled    bool   `mapstructure:"enabled"`
	Max        int    `mapstructure:"max"`
	Expiration string `mapstructure:"expiration"`
}

type RequestID

type RequestID struct {
	Enabled bool `mapstructure:"enabled"`
}

type SwaggerUI

type SwaggerUI struct {
	Enabled bool   `mapstructure:"enabled"`
	Path    string `mapstructure:"path"`
}

Jump to

Keyboard shortcuts

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