gin

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gin

type Gin struct {
	// web server descriptive name (used for display and logging only)
	Name string

	// web server port to run gin web server
	Port uint

	// web server routes to handle
	// string = routeGroup path if defined, otherwise, if * refers to base
	Routes map[string][]*RouteDefinition
	// contains filtered or unexported fields
}

Gin struct provides a wrapper for gin-gonic based web server operations

Name = (required) web server descriptive display name Port = (required) tcp port that this web server will run on Routes = (required) map of http route handlers to be registered, middleware to be configured,

for gin engine or route groups,
key = * indicates base gin engine routes, otherwise key refers to routeGroup to be created

func NewServer

func NewServer(name string, port uint, releaseMode bool) *Gin

NewServer returns a gin-gongic web server wrapper ready for setup

func (*Gin) RunServer

func (g *Gin) RunServer() error

RunServer starts gin-gonic web server, method will run in blocking mode, until gin server exits, if run server failed, an error is returned

type Route

type Route struct {
	// relative path to the endpoint for the route to handle
	RelativePath string

	// http method such as GET, POST, PUT, DELETE
	Method ginhttpmethod.GinHttpMethod

	// input value binding to be performed
	Binding ginbindtype.GinBindType

	// actual handler method to be triggered,
	// bindingInput if any, is the binding resolved object passed into the handler method
	Handler func(c *gin.Context, bindingInput interface{})
}

Route struct defines each http route handler endpoint

RelativePath = (required) route path such as /HelloWorld, this is the path to trigger the route handler Method = (required) GET, POST, PUT, DELETE Binding = (optional) various input data binding to target type option Handler = (required) function handler to be executed per method defined (actual logic goes inside handler)

  1. gin.Context Value Return Helpers: a) c.String(), c.HTML(), c.JSON(), c.JSONP(), c.PureJSON(), c.AsciiJSON(), c.SecureJSON(), c.XML(), c.YAML(), c.ProtoBuf(), c.Redirect(), c.Data(), c.DataFromReader(), c.Render()

type RouteDefinition added in v1.0.5

type RouteDefinition struct {
	Routes                      []*Route
	CorsConfig                  *cors.Config
	MaxLimitConfig              *int
	PerClientIpQpsConfig        *int
	PerClientIpBurstConfig      *int
	PerClientIpLimiterTTLConfig *time.Duration
	CustomMiddlewareHandlers    []gin.HandlerFunc
}

RouteDefinition struct contains per route group or gin engine's handlers and middleware

Routes = (required) one or more route handlers defined for current route group or base engine CorsConfig = (optional) current cors middleware to use if setup for current route group or base engine MaxLimitConfig = (optional) current max rate limit middleware, controls how many concurrent handlers can process actions for the current route group or base engine PerClientIpQpsConfig / BurstConfig / LimiterTTLConfig = (optional) to enable per client Ip QPS limiter middleware, all 3 options must be set

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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