Help us shape the future of Go! Take the 2026 Go Developer Survey

gin

package
v1.0.3 Latest Latest
Warning

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

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

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
	Routes []*Route
	// contains filtered or unexported fields
}

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

func NewServer

func NewServer() *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 go routine so it does not block 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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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