httputil

package
v1.0.60 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Provides HTTP server implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*gin.Engine
	// contains filtered or unexported fields
}

Server is an object representing gin.Engine and implementing the lifecycle.Service interface.

func NewServer

func NewServer(opts ...ServerOpt) *Server

NewServer create new Server using global configuration and provided options. Function reads "http.address" config key to determine an address for HTTP listener (by default: 0.0.0.0:8080). Other config keys are "http.security.headers" which controls whether server should automatically include HTTP security headers to its responses and "http.shutdown.timeout" which defines a maximum time of shutdown in seconds.

func (*Server) Start

func (server *Server) Start() error

Start implements the interface of lifecycle.Service

func (*Server) Stop

func (server *Server) Stop()

Stop implements the interface of lifecycle.Service

type ServerOpt

type ServerOpt = func(*serverConfig)

ServerOpt is an option to be specified to NewServer.

func Address

func Address(address string) ServerOpt

Address sets address of HTTP server

func CustomConfig

func CustomConfig(customConfig *config.Config) ServerOpt

CustomConfig makes NewServer overwrite keys from global configuration with these from the specified one.

func SecurityHeaders

func SecurityHeaders(securityHeaders bool) ServerOpt

SecurityHeaders defines whether to include HTTP security headers to all responses or not

func ShutdownTimeout

func ShutdownTimeout(seconds int64) ServerOpt

ShutdownTimeout defines a maximal timeout of HTTP server shutdown

Jump to

Keyboard shortcuts

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