http

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

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

Go to latest
Published: Dec 11, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CORSDefaultAllowMethods = []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"}
	// CORS safelisted-request-header: https://fetch.spec.whatwg.org/#cors-safelisted-request-header
	// CORS forbidden-header-name: https://fetch.spec.whatwg.org/#forbidden-header-name
	CORSDefaultAllowHeaders = []string{
		"Accept",
		"Accept-Charset",
		"Accept-Encoding",
		"Accept-Language",
		"Content-Language",
		"Content-Length",
		"Content-Type",
		"Host",
		"Origin",
	}
	CORSDefaultAllowCredentials = true
	CORSDefaultMaxAge           = 12 * time.Hour
)

Functions

This section is empty.

Types

type RouterGroup

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

RouterGroup groups path under one path prefix.

func (*RouterGroup) DELETE

func (rg *RouterGroup) DELETE(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

DELETE registers HTTP server endpoint with Delete method.

func (*RouterGroup) GET

func (rg *RouterGroup) GET(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

GET registers HTTP server endpoint with Get method.

func (*RouterGroup) Group

func (rg *RouterGroup) Group(prefix string) *RouterGroup

Group creates new RouterGroup with the given path prefix.

func (*RouterGroup) HEAD

func (rg *RouterGroup) HEAD(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

HEAD registers HTTP server endpoint with Head method.

func (*RouterGroup) OPTIONS

func (rg *RouterGroup) OPTIONS(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

OPTIONS registers HTTP server endpoint with Options method.

func (*RouterGroup) PATCH

func (rg *RouterGroup) PATCH(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

PATCH registers HTTP server endpoint with Patch method.

func (*RouterGroup) POST

func (rg *RouterGroup) POST(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

POST registers HTTP server endpoint with Post method.

func (*RouterGroup) PUT

func (rg *RouterGroup) PUT(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

PUT registers HTTP server endpoint with Put method.

type Server

type Server struct {
	RouterGroup

	CORS *cors.Config
	Port string
	// contains filtered or unexported fields
}

Server represents the implementation of HTTP server object.

func NewServer

func NewServer(port string, enableCORS bool, enablePredefinedRoutes bool) *Server

NewServer creates new HTTP server.

func (*Server) AddMiddleware

func (s *Server) AddMiddleware(h gin.HandlerFunc)

AddMiddleware adds a gin middleware the HTTP server.

func (*Server) DELETE

func (s *Server) DELETE(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

DELETE registers HTTP server endpoint with Delete method.

func (*Server) GET

func (s *Server) GET(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

GET registers HTTP server endpoint with Get method.

func (*Server) GetRoutePaths

func (s *Server) GetRoutePaths() []string

GetRoutePaths retrieves all route paths registerd to this HTTP server.

func (*Server) HEAD

func (s *Server) HEAD(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

HEAD registers HTTP server endpoint with Head method.

func (*Server) LoggerSkipPaths

func (s *Server) LoggerSkipPaths(paths ...string)

LoggerSkipPaths registers endpoint paths that you want to skip from being logged by the logger middleware.

func (*Server) OPTIONS

func (s *Server) OPTIONS(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

OPTIONS registers HTTP server endpoint with Options method.

func (*Server) PATCH

func (s *Server) PATCH(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

PATCH registers HTTP server endpoint with Patch method.

func (*Server) POST

func (s *Server) POST(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

POST registers HTTP server endpoint with Post method.

func (*Server) PUT

func (s *Server) PUT(relativePath string, logPayload bool, handlers ...gin.HandlerFunc)

PUT registers HTTP server endpoint with Put method.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server.

func (*Server) Stop

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

Stop stops the HTTP server.

Directories

Path Synopsis
middleware
logger
Package logger is based on: https://github.com/gin-contrib/logger
Package logger is based on: https://github.com/gin-contrib/logger

Jump to

Keyboard shortcuts

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