web

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	JSON(statusCode int, obj interface{})
	String(statusCode int, format string, values ...interface{})
	Param(key string) string
	Query(key string) string
	BindJSON(obj interface{}) error
	Next()
	Request() *http.Request
	ClientIP() string
	SetHeader(key, value string)
}

Context abstracts the HTTP context used by the framework

func NewGinContext

func NewGinContext(ctx *gin.Context) Context

NewGinContext wraps Gin's context

type HandlerFunc

type HandlerFunc func(ctx Context)

HandlerFunc defines a generic HTTP handler function type

type Option

type Option func(*Options)

func WithAddress

func WithAddress(address string) Option

WithAddress sets the address for the server

func WithMiddleware

func WithMiddleware(middleware ...HandlerFunc) Option

WithMiddleware adds middleware to the server

func WithMode

func WithMode(mode string) Option

WithMode sets the mode for the server

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

WithShutdownTimeout sets the shutdown timeout for the server

type Options

type Options struct {
	Address         string
	Mode            string
	ShutdownTimeout time.Duration
	Middleware      []HandlerFunc
	Logger          gin.HandlerFunc // Custom logger middleware
}

Options contains configurable settings for the Gin web server

type RouterGroup

type RouterGroup interface {
	GET(route string, handler HandlerFunc)
	POST(route string, handler HandlerFunc)
	PUT(route string, handler HandlerFunc)
	PATCH(route string, handler HandlerFunc)
	DELETE(route string, handler HandlerFunc)
	OPTIONS(route string, handler HandlerFunc)
	HEAD(route string, handler HandlerFunc)
}

RouterGroup abstracts route grouping

type Server

type Server interface {
	GET(route string, handler HandlerFunc)
	POST(route string, handler HandlerFunc)
	PUT(route string, handler HandlerFunc)
	PATCH(route string, handler HandlerFunc)
	DELETE(route string, handler HandlerFunc)
	OPTIONS(route string, handler HandlerFunc)
	HEAD(route string, handler HandlerFunc)
	Group(prefix string) RouterGroup
	Use(middleware ...HandlerFunc)
	Start() error
	Stop() error
}

Server defines the abstraction for the web server

func NewGinServer

func NewGinServer(opts ...Option) Server

Jump to

Keyboard shortcuts

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