SpringEcho

package module
v1.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: Apache-2.0 Imports: 17 Imported by: 4

README

spring-echo

封装 github.com/labstack/echo 实现的 Web 框架。

创建 Web 容器
NewContainer

创建 echo 实现的 Web 容器。

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

适配 echo 形式的处理函数。

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

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

func Filter(fn echo.MiddlewareFunc) SpringWeb.Filter {}
EchoContext

将 SpringWeb.Context 转换为 echo.Context。

func EchoContext(ctx SpringWeb.Context) echo.Context {}
WebContext

将 echo.Context 转换为 SpringWeb.Context。

func WebContext(echoCtx echo.Context) SpringWeb.Context {}

Documentation

Overview

Package SpringEcho 封装 github.com/labstack/echo 实现的 Web 框架

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EchoContext

func EchoContext(ctx web.Context) echo.Context

EchoContext 将 web.Context 转换为 echo.Context

func Filter

func Filter(fn echo.MiddlewareFunc) web.Filter

Filter 适配 echo 形式的中间件函数

func Handler added in v1.1.0

func Handler(fn echo.HandlerFunc) web.Handler

Handler 适配 echo 形式的处理函数

func HandlerWrapper

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

HandlerWrapper Web 处理函数包装器

func WebContext

func WebContext(echoCtx echo.Context) web.Context

WebContext 将 echo.Context 转换为 web.Context

Types

type Container

type Container struct {
	*web.AbstractContainer
	// contains filtered or unexported fields
}

Container echo 实现的 Web 容器

func NewContainer

func NewContainer(config web.ContainerConfig) *Container

NewContainer 创建 echo 实现的 Web 容器

func (*Container) Start

func (c *Container) Start() error

Start 启动 Web 容器

func (*Container) Stop

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

Stop 停止 Web 容器

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context 适配 echo 的 Web 上下文

func NewContext

func NewContext(fn web.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(contentType string, b []byte)

Blob sends a blob response with 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) Context

func (ctx *Context) Context() context.Context

Context 返回 Request 绑定的 context.Context 对象

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) 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(html string)

HTML sends an HTTP response.

func (*Context) HTMLBlob

func (ctx *Context) HTMLBlob(b []byte)

HTMLBlob sends an HTTP blob response.

func (*Context) Handler

func (ctx *Context) Handler() web.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(i interface{})

JSON sends a JSON response.

func (*Context) JSONBlob

func (ctx *Context) JSONBlob(b []byte)

JSONBlob sends a JSON blob response.

func (*Context) JSONP

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

JSONP sends a JSONP response.

func (*Context) JSONPBlob

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

JSONPBlob sends a JSONP blob response.

func (*Context) JSONPretty

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

JSONPretty sends a pretty-print JSON.

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() web.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) 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) String

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

String writes the given string into the response body.

func (*Context) XML

func (ctx *Context) XML(i interface{})

XML sends an XML response.

func (*Context) XMLBlob

func (ctx *Context) XMLBlob(b []byte)

XMLBlob sends an XML blob response.

func (*Context) XMLPretty

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

XMLPretty sends a pretty-print XML.

Jump to

Keyboard shortcuts

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