ginS

package
v0.0.0-...-8746e94 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0, MIT Imports: 4 Imported by: 0

README

Gin Default Server

This is API experiment for Gin.

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/ginS"
)

func main() {
	ginS.GET("/", func(c *gin.Context) { c.String(200, "Hello World") })
	ginS.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

Any is a wrapper for Engine.Any.

func DELETE

func DELETE(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

DELETE is a shortcut for router.Handle("DELETE", path, handle)

func GET

func GET(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

GET is a shortcut for router.Handle("GET", path, handle)

func Group

func Group(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup

Group creates a new router group. You should add all the routes that have common middlewares or the same path prefix. For example, all the routes that use a common middleware for authorization could be grouped.

func HEAD(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

HEAD is a shortcut for router.Handle("HEAD", path, handle)

func Handle

func Handle(httpMethod, relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

Handle is a wrapper for Engine.Handle.

func LoadHTMLFiles

func LoadHTMLFiles(files ...string)

LoadHTMLFiles is a wrapper for Engine.LoadHTMLFiles.

func LoadHTMLGlob

func LoadHTMLGlob(pattern string)

LoadHTMLGlob is a wrapper for Engine.LoadHTMLGlob.

func NoMethod

func NoMethod(handlers ...gin.HandlerFunc)

NoMethod is a wrapper for Engine.NoMethod.

func NoRoute

func NoRoute(handlers ...gin.HandlerFunc)

NoRoute adds handlers for NoRoute. It returns a 404 code by default.

func OPTIONS

func OPTIONS(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle)

func PATCH

func PATCH(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

PATCH is a shortcut for router.Handle("PATCH", path, handle)

func POST

func POST(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

POST is a shortcut for router.Handle("POST", path, handle)

func PUT

func PUT(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

PUT is a shortcut for router.Handle("PUT", path, handle)

func Routes

func Routes() gin.RoutesInfo

Routes returns a slice of registered routes.

func Run

func Run(addr ...string) (err error)

Run attaches to a http.Server and starts listening and serving HTTP requests. It is a shortcut for http.ListenAndServe(addr, router) Note: this method will block the calling goroutine indefinitely unless an error happens.

func RunFd

func RunFd(fd int) (err error)

RunFd attaches the router to a http.Server and starts listening and serving HTTP requests through the specified file descriptor. Note: the method will block the calling goroutine indefinitely unless on error happens.

func RunTLS

func RunTLS(addr, certFile, keyFile string) (err error)

RunTLS attaches to a http.Server and starts listening and serving HTTPS requests. It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router) Note: this method will block the calling goroutine indefinitely unless an error happens.

func RunUnix

func RunUnix(file string) (err error)

RunUnix attaches to a http.Server and starts listening and serving HTTP requests through the specified unix socket (i.e. a file) Note: this method will block the calling goroutine indefinitely unless an error happens.

func SetHTMLTemplate

func SetHTMLTemplate(templ *template.Template)

SetHTMLTemplate is a wrapper for Engine.SetHTMLTemplate.

func Static

func Static(relativePath, root string) gin.IRoutes

Static serves files from the given file system root. Internally a http.FileServer is used, therefore http.NotFound is used instead of the Router's NotFound handler. To use the operating system's file system implementation, use :

router.Static("/static", "/var/www")

func StaticFS

func StaticFS(relativePath string, fs http.FileSystem) gin.IRoutes

StaticFS is a wrapper for Engine.StaticFS.

func StaticFile

func StaticFile(relativePath, filepath string) gin.IRoutes

StaticFile is a wrapper for Engine.StaticFile.

func Use

func Use(middlewares ...gin.HandlerFunc) gin.IRoutes

Use attaches a global middleware to the router. i.e. the middlewares attached through Use() will be included in the handlers chain for every single request. Even 404, 405, static files... For example, this is the right place for a logger or error management middleware.

Types

This section is empty.

Jump to

Keyboard shortcuts

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