server

package
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStdServer added in v1.5.1

func NewStdServer(cfg *Config, h http.Handler) *http.Server

New creates a standard HTTP server using the provided configuration and handler.

Types

type Config

type Config struct {
	Port         string        // Port on which the server listens
	ReadTimeout  time.Duration // Maximum duration for reading the entire request
	WriteTimeout time.Duration // Maximum duration before timing out writes
	IdleTimeout  time.Duration // Maximum time to wait for the next request
}

Config contains configuration settings for an server.

func NewConfig

func NewConfig(port string, read, write, idle time.Duration) *Config

func (*Config) WithIdleTimeout

func (c *Config) WithIdleTimeout(timeout time.Duration) *Config

WithIdleTimeout sets the IdleTimeout field and returns the updated Config.

func (*Config) WithPort

func (c *Config) WithPort(port string) *Config

WithPort sets the Port field and returns the updated Config.

func (*Config) WithReadTimeout

func (c *Config) WithReadTimeout(timeout time.Duration) *Config

WithReadTimeout sets the ReadTimeout field and returns the updated Config.

func (*Config) WithWriteTimeout

func (c *Config) WithWriteTimeout(timeout time.Duration) *Config

WithWriteTimeout sets the WriteTimeout field and returns the updated Config.

type Server added in v1.5.1

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

func New

func New(cfg *Config, log *slog.Logger, h http.Handler) *Server

func (*Server) Shutdown added in v1.5.1

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

func (*Server) Start added in v1.5.1

func (s *Server) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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