SpringGin

package
v0.0.0-...-0e333a0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentType        = "Content-Type"
	HeaderContentDisposition = "Content-Disposition"
	HeaderXForwardedProto    = "X-Forwarded-Proto"
	HeaderXForwardedProtocol = "X-Forwarded-Protocol"
	HeaderXForwardedSsl      = "X-Forwarded-Ssl"
	HeaderXUrlScheme         = "X-Url-Scheme"
)
View Source
const (
	MIMEApplicationJSON                  = "application/json"
	MIMEApplicationJSONCharsetUTF8       = MIMEApplicationJSON + "; " + charsetUTF8
	MIMEApplicationXML                   = "application/xml"
	MIMEApplicationXMLCharsetUTF8        = MIMEApplicationXML + "; " + charsetUTF8
	MIMEApplicationJavaScript            = "application/javascript"
	MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8
	MIMEMultipartForm                    = "multipart/form-data"
	MIMETextHTML                         = "text/html"
	MIMETextHTMLCharsetUTF8              = MIMETextHTML + "; " + charsetUTF8
)

Variables

This section is empty.

Functions

func HandlerWrapper

func HandlerWrapper(path string, fn SpringWeb.Handler) func(*gin.Context)

Web 处理函数包装器

Types

type Container

type Container struct {
	HttpServer *http.Server
	GinEngine  *gin.Engine
}

适配 gin 的 Web 容器

func NewContainer

func NewContainer() *Container

工厂函数

func (*Container) DELETE

func (c *Container) DELETE(path string, fn SpringWeb.Handler)

func (*Container) GET

func (c *Container) GET(path string, fn SpringWeb.Handler)

func (*Container) HEAD

func (c *Container) HEAD(path string, fn SpringWeb.Handler)

func (*Container) OPTIONS

func (c *Container) OPTIONS(path string, fn SpringWeb.Handler)

func (*Container) PATCH

func (c *Container) PATCH(path string, fn SpringWeb.Handler)

func (*Container) POST

func (c *Container) POST(path string, fn SpringWeb.Handler)

func (*Container) PUT

func (c *Container) PUT(path string, fn SpringWeb.Handler)

func (*Container) Start

func (c *Container) Start(address string) error

func (*Container) StartTLS

func (c *Container) StartTLS(address string, certFile, keyFile string) error

func (*Container) Stop

func (c *Container) Stop()

type Context

type Context struct {
	*SpringTrace.DefaultTraceContext

	// gin 上下文对象
	GinContext *gin.Context

	// 处理器 Path
	HandlerPath string

	// Web 处理函数
	HandlerFunc SpringWeb.Handler
	// contains filtered or unexported fields
}

适配 gin 的 Web 上下文

func (*Context) Attachment

func (ctx *Context) Attachment(file string, name string)

func (*Context) Bind

func (ctx *Context) Bind(i interface{}) error

func (*Context) Blob

func (ctx *Context) Blob(code int, contentType string, b []byte)

func (*Context) ClientIP

func (ctx *Context) ClientIP() string

func (*Context) ContentType

func (ctx *Context) ContentType() string

func (*Context) Cookie

func (ctx *Context) Cookie(name string) (*http.Cookie, error)

func (*Context) Cookies

func (ctx *Context) Cookies() []*http.Cookie

func (*Context) Error

func (ctx *Context) Error(err error)

func (*Context) File

func (ctx *Context) File(file string)

func (*Context) FormFile

func (ctx *Context) FormFile(name string) (*multipart.FileHeader, error)

func (*Context) FormParams

func (ctx *Context) FormParams() (url.Values, error)

func (*Context) FormValue

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

func (*Context) Get

func (ctx *Context) Get(key string) interface{}

func (*Context) GetHeader

func (ctx *Context) GetHeader(key string) string

func (*Context) GetRawData

func (ctx *Context) GetRawData() ([]byte, error)

func (*Context) HTML

func (ctx *Context) HTML(code int, html string)

func (*Context) HTMLBlob

func (ctx *Context) HTMLBlob(code int, b []byte)

func (*Context) Handler

func (ctx *Context) Handler() SpringWeb.Handler

func (*Context) Header

func (ctx *Context) Header(key, value string)

func (*Context) Inline

func (ctx *Context) Inline(file string, name string)

func (*Context) IsTLS

func (ctx *Context) IsTLS() bool

func (*Context) IsWebSocket

func (ctx *Context) IsWebSocket() bool

func (*Context) JSON

func (ctx *Context) JSON(code int, i interface{})

func (*Context) JSONBlob

func (ctx *Context) JSONBlob(code int, b []byte)

func (*Context) JSONP

func (ctx *Context) JSONP(code int, callback string, i interface{})

func (*Context) JSONPBlob

func (ctx *Context) JSONPBlob(code int, callback string, b []byte)

func (*Context) JSONPretty

func (ctx *Context) JSONPretty(code int, i interface{}, indent string)

func (*Context) MultipartForm

func (ctx *Context) MultipartForm() (*multipart.Form, error)

func (*Context) NativeContext

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

func (*Context) NoContent

func (ctx *Context) NoContent(code int)

func (*Context) Path

func (ctx *Context) Path() string

func (*Context) PathParam

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

func (*Context) PathParamNames

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

func (*Context) PathParamValues

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

func (*Context) QueryParam

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

func (*Context) QueryParams

func (ctx *Context) QueryParams() url.Values

func (*Context) QueryString

func (ctx *Context) QueryString() string

func (*Context) Redirect

func (ctx *Context) Redirect(code int, url string)

func (*Context) Request

func (ctx *Context) Request() *http.Request

func (*Context) SSEvent

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

func (*Context) SaveUploadedFile

func (ctx *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error

func (*Context) Scheme

func (ctx *Context) Scheme() string

func (*Context) Set

func (ctx *Context) Set(key string, val interface{})

func (*Context) SetCookie

func (ctx *Context) SetCookie(cookie *http.Cookie)

func (*Context) Status

func (ctx *Context) Status(code int)

func (*Context) Stream

func (ctx *Context) Stream(code int, contentType string, r io.Reader)

func (*Context) String

func (ctx *Context) String(code int, format string, values ...interface{})

func (*Context) XML

func (ctx *Context) XML(code int, i interface{})

func (*Context) XMLBlob

func (ctx *Context) XMLBlob(code int, b []byte)

func (*Context) XMLPretty

func (ctx *Context) XMLPretty(code int, i interface{}, indent string)

Jump to

Keyboard shortcuts

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