SpringGin

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 11 Imported by: 3

README

spring-gin

[仅发布] 该项目仅为最终发布,开发请关注 go-spring 项目。

封装 github.com/gin-gonic/gin 实现的 Web 框架。

创建 Web 容器
NewContainer

创建 gin 实现的 WebContainer。

func NewContainer(config SpringWeb.ContainerConfig) *Container {}
适配 gin 框架
Handler

适配 gin 形式的处理函数。

func Handler(fn gin.HandlerFunc) SpringWeb.Handler {}
Filter

适配 gin 形式的中间件函数。

func Filter(fn gin.HandlerFunc) SpringWeb.Filter {}
GinContext

将 SpringWeb.WebContext 转换为 *gin.Context。

func GinContext(webCtx SpringWeb.WebContext) *gin.Context {}
WebContext

将 *gin.Context 转换为 SpringWeb.WebContext。

func WebContext(ginCtx *gin.Context) SpringWeb.WebContext {}

Documentation

Overview

Package SpringGin 封装 github.com/gin-gonic/gin 实现的 Web 框架

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(fn gin.HandlerFunc) web.Filter

Filter Web Gin 中间件适配器

func GinContext

func GinContext(c web.Context) *gin.Context

GinContext 将 web.Context 转换为 *gin.Context

func Handler added in v1.1.0

func Handler(fn gin.HandlerFunc) web.Handler

Handler 适配 gin 形式的处理函数

func New added in v1.1.0

func New(config web.ServerConfig) web.Server

New 创建 gin 实现的 web 服务器

func WebContext

func WebContext(c *gin.Context) web.Context

WebContext 将 *gin.Context 转换为 web.Context

Types

type Context

type Context struct {
	*web.BaseContext
	// contains filtered or unexported fields
}

Context 适配 gin 的 Web 上下文

func (*Context) NativeContext

func (ctx *Context) NativeContext() interface{}

NativeContext 返回封装的底层上下文对象

func (*Context) PathParam

func (ctx *Context) PathParam(name string) string

PathParam returns path parameter by name.

func (*Context) PathParamNames

func (ctx *Context) PathParamNames() []string

PathParamNames returns path parameter names.

func (*Context) PathParamValues

func (ctx *Context) PathParamValues() []string

PathParamValues returns path parameter values.

func (*Context) SSEvent

func (ctx *Context) SSEvent(name string, message interface{})

SSEvent writes a Server-Sent Event into the body stream.

type Response added in v1.1.1

type Response struct {
	gin.ResponseWriter
}

func (*Response) Get added in v1.1.1

func (resp *Response) Get() http.ResponseWriter

func (*Response) Set added in v1.1.1

func (resp *Response) Set(w http.ResponseWriter)

Jump to

Keyboard shortcuts

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