rest

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port                    int           `env:"PORT" envDefault:"8080"`
	RPS                     int           `env:"REQUESTS_PER_SECOND" envDefault:"100"`
	ReadTimeout             time.Duration `env:"READ_TIMEOUT" envDefault:"5s"`
	WriteTimeout            time.Duration `env:"WRITE_TIMEOUT" envDefault:"10s"`
	IdleTimeout             time.Duration `env:"IDLE_TIMEOUT" envDefault:"15s"`
	CORSMaxAge              int           `env:"CORS_MAX_AGE" envDefault:"86400"`
	CORSExtraAllowedHeaders string        `env:"CORS_EXTRA_ALLOWED_HEADERS" envDefault:""`
}

Config holds the configuration for the REST server. The default values are used if the environment variables are not set. The environment variables are: - PORT: the port the server listens on - REQUESTS_PER_SECOND: the number of requests per second the server can handle (if 0, the rate limiter is disabled) - READ_TIMEOUT: the read timeout for the server (if 0, no timeout is set) - WRITE_TIMEOUT: the write timeout for the server (if 0, no timeout is set) - IDLE_TIMEOUT: the idle timeout for the server (if 0, no timeout is set) - CORS_MAX_AGE: the max age for the CORS header - CORS_EXTRA_ALLOWED_HEADERS: the extra allowed headers for the CORS header (comma separated)

func GetConfigFromEnv

func GetConfigFromEnv() (*Config, error)

GetConfigFromEnv gets the configuration from the environment variables.

type Server

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

Server is the REST server for the shield API

func New

func New(cfg *Config, projectApp *projectapp.ProjectApplication, shareApp *shareapp.ShareApplication, authManager *authenticationmgr.Manager) *Server

New creates a new REST server

func (*Server) Start

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

Start starts the REST server

func (*Server) Stop

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

Stop stops the REST server gracefully

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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