serving

package
v0.0.0-...-5aad56d Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server represents the HTTP server

func NewServer

func NewServer(options *ServerOptions) (*Server, error)

NewServer creates a new server instance

func (*Server) Run

func (s *Server) Run() error

Run starts the server

func (*Server) Shutdown

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

Shutdown gracefully shuts down the server

type ServerOptions

type ServerOptions struct {
	Port         int           `json:"port"`
	DBPath       string        `json:"dbPath"`
	LogLevel     string        `json:"logLevel"`
	EnablePprof  bool          `json:"enablePprof"`
	MetricsPort  int           `json:"metricsPort"`
	RateLimit    int           `json:"rateLimit"`
	EnableCORS   bool          `json:"enableCORS"`
	CORSOrigins  []string      `json:"corsOrigins"`
	ReadTimeout  time.Duration `json:"readTimeout"`
	WriteTimeout time.Duration `json:"writeTimeout"`
}

ServerOptions contains the options for the server

func NewServerOptions

func NewServerOptions() *ServerOptions

NewServerOptions creates a new ServerOptions with default values

func (*ServerOptions) AddFlags

func (o *ServerOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags to the given FlagSet

func (*ServerOptions) Complete

func (o *ServerOptions) Complete() error

Complete completes the options

func (*ServerOptions) Validate

func (o *ServerOptions) Validate() error

Validate validates the options

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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