SpringEcho

package module
v0.0.0-...-7c64363 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

go-spring-echo

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Echo

func Echo(fn echo.HandlerFunc) SpringWeb.Handler

Echo Web Echo 适配函数

func EchoContext

func EchoContext(webCtx SpringWeb.WebContext) echo.Context

EchoContext 将 SpringWeb.WebContext 转换为 echo.Context

func Filter

func Filter(fn echo.MiddlewareFunc) SpringWeb.Filter

Filter Web Echo 中间件适配器

func HandlerWrapper

func HandlerWrapper(fn SpringWeb.Handler, wildCardName string, filters []SpringWeb.Filter) echo.HandlerFunc

HandlerWrapper Web 处理函数包装器

func WebContext

func WebContext(echoCtx echo.Context) SpringWeb.WebContext

WebContext 将 echo.Context 转换为 SpringWeb.WebContext

Types

type Container

type Container struct {
	*SpringWeb.BaseWebContainer
	// contains filtered or unexported fields
}

Container 适配 echo 的 Web 容器

func NewContainer

func NewContainer(config SpringWeb.ContainerConfig) *Container

NewContainer Container 的构造函数

func (*Container) SetEchoServer deprecated

func (c *Container) SetEchoServer(e *echo.Echo)

Deprecated: Filter 机制可完美替代中间件机制,不再需要定制化

func (*Container) Start

func (c *Container) Start()

Start 启动 Web 容器,非阻塞

func (*Container) Stop

func (c *Container) Stop(ctx context.Context)

Stop 停止 Web 容器,阻塞

type Context

type Context struct {
	// LoggerContext 日志接口上下文
	SpringLogger.LoggerContext
	// contains filtered or unexported fields
}

Context 适配 echo 的 Web 上下文

func NewContext

func NewContext(fn SpringWeb.Handler, wildCardName string, echoCtx echo.Context) *Context

NewContext Context 的构造函数

func (*Context) Attachment

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

Attachment sends a response as attachment

func (*Context) Bind

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

Bind binds the request body into provided type `i`.

func (*Context) Blob

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

Blob sends a blob response with status code and content type.

func (*Context) ClientIP

func (ctx *Context) ClientIP() string

ClientIP implements a best effort algorithm to return the real client IP.

func (*Context) ContentType

func (ctx *Context) ContentType() string

ContentType returns the Content-Type header of the request.

func (*Context) Cookie

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

Cookie returns the named cookie provided in the request.

func (*Context) Cookies

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

Cookies returns the HTTP cookies sent with the request.

func (*Context) File

func (ctx *Context) File(file string)

File sends a response with the content of the file.

func (*Context) FormFile

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

FormFile returns the multipart form file for the provided name.

func (*Context) FormParams

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

FormParams returns the form parameters as `url.Values`.

func (*Context) FormValue

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

FormValue returns the form field value for the provided name.

func (*Context) Get

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

Get retrieves data from the context.

func (*Context) GetHeader

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

GetHeader returns value from request headers.

func (*Context) GetRawData

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

GetRawData return stream data.

func (*Context) HTML

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

HTML sends an HTTP response with status code.

func (*Context) HTMLBlob

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

HTMLBlob sends an HTTP blob response with status code.

func (*Context) Handler

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

Handler returns the matched handler by router.

func (*Context) Header

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

Header is a intelligent shortcut for c.Writer.Header().Set(key, value).

func (*Context) Inline

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

Inline sends a response as inline

func (*Context) IsTLS

func (ctx *Context) IsTLS() bool

IsTLS returns true if HTTP connection is TLS otherwise false.

func (*Context) IsWebSocket

func (ctx *Context) IsWebSocket() bool

IsWebSocket returns true if HTTP connection is WebSocket otherwise false.

func (*Context) JSON

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

JSON sends a JSON response with status code.

func (*Context) JSONBlob

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

JSONBlob sends a JSON blob response with status code.

func (*Context) JSONP

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

JSONP sends a JSONP response with status code.

func (*Context) JSONPBlob

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

JSONPBlob sends a JSONP blob response with status code.

func (*Context) JSONPretty

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

JSONPretty sends a pretty-print JSON with status code.

func (*Context) MultipartForm

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

MultipartForm returns the multipart form.

func (*Context) NativeContext

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

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

func (*Context) NoContent

func (ctx *Context) NoContent(code int)

NoContent sends a response with no body and a status code.

func (*Context) Path

func (ctx *Context) Path() string

Path returns the registered path for the handler.

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) QueryParam

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

QueryParam returns the query param for the provided name.

func (*Context) QueryParams

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

QueryParams returns the query parameters as `url.Values`.

func (*Context) QueryString

func (ctx *Context) QueryString() string

QueryString returns the URL query string.

func (*Context) Redirect

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

Redirect redirects the request to a provided URL with status code.

func (*Context) Request

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

Request returns `*http.Request`.

func (*Context) ResponseWriter

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

ResponseWriter returns `http.ResponseWriter`.

func (*Context) SSEvent

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

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

func (*Context) SaveUploadedFile

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

SaveUploadedFile uploads the form file to specific dst.

func (*Context) Scheme

func (ctx *Context) Scheme() string

Scheme returns the HTTP protocol scheme, `http` or `https`.

func (*Context) Set

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

Set saves data in the context.

func (*Context) SetCookie

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

SetCookie adds a `Set-Cookie` header in HTTP response.

func (*Context) SetRequest

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

SetRequest sets `*http.Request`.

func (*Context) Status

func (ctx *Context) Status(code int)

Status sets the HTTP response code.

func (*Context) Stream

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

Stream sends a streaming response with status code and content type.

func (*Context) String

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

String writes the given string into the response body.

func (*Context) XML

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

XML sends an XML response with status code.

func (*Context) XMLBlob

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

XMLBlob sends an XML blob response with status code.

func (*Context) XMLPretty

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

XMLPretty sends a pretty-print XML with status code.

Jump to

Keyboard shortcuts

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