server

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Copyright (c) 2025 EterLine (Andrew) This file is part of fstmon. Licensed under the MIT License. See the LICENSE file for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServerTlsConfig

func NewServerTlsConfig() *tls.Config

NewServerTlsConfig – creates or returns singleton TLS config for servers. PreferServerCipherSuites is always true. Min TLS 1.2, Max TLS 1.3.

Types

type Server

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

Server – HTTP server wrapper with optional TLS and graceful shutdown.

Holds underlying http.Server and provides Run and Close methods.

func NewServer

func NewServer(handler http.Handler, opts ...ServerOption) *Server

NewServer – creates a new Server with given HTTP handler and options.

func (*Server) Close

func (s *Server) Close() error

Close – immediately shuts down the server with configured timeout.

func (*Server) Run

func (s *Server) Run(ctx context.Context, addr, key, crt string) error

Run – starts the server on the given address.

If TLS certificate and key paths are provided, runs TLS server.
Listens for context cancellation to shutdown gracefully.

type ServerOption

type ServerOption func(*Server)

ServerOption – functional option type for configuring Server.

func WithDisabledDefaultHttp2Map

func WithDisabledDefaultHttp2Map() ServerOption

WithDisabledDefaultHttp2Map – disable default HTTP/2 map.

func WithShutdownTimeout

func WithShutdownTimeout(d time.Duration) ServerOption

WithShutdownTimeout – sets shutdown timeout duration.

func WithTLS

func WithTLS(cfg *tls.Config) ServerOption

WithTLS – enables TLS with provided tls.Config.

Jump to

Keyboard shortcuts

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