echo

package
v0.0.0-...-8c01709 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(err error, ctx echo.Context)

ErrorHandler http 错误处理器

func New

func New(cfg Config) *echo.Echo

func RenderBadRequest

func RenderBadRequest(c echo.Context, err error) error

func RenderOK

func RenderOK(c echo.Context, data interface{}) error

Types

type Config

type Config struct {
	LogWriter io.Writer
	// Address 服务监听端口
	Address string `yaml:"address" json:"address" xml:"address"`
	// KeepAlive
	KeepAlive bool `yaml:"keep_alive" json:"keep_alive" xml:"keep_alive"`
	// AccessLogFormat http access 日志格式
	AccessLogFormat string `yaml:"access_log_format" json:"access_log_format" xml:"access_log_format"`
	// CORSConfig 跨域配置
	CORSConfig *middleware.CORSConfig `yaml:"cors" json:"cors_config" xml:"cors_config"`
	// SecureConfig 安全配置
	SecureConfig *middleware.SecureConfig `yaml:"secure" json:"secure_config" xml:"secure_config"`
	// RewriteRules 规则重写URL路径配置
	RewriteRules map[string]string `yaml:"rewrite_rules" json:"rewrite_rules" xml:"rewrite_rules"`
	// CookieDomain cookie域
	CookieDomain string `yaml:"cookie_domain" json:"cookie_domain" xml:"cookie_domain"`
	// StaticPrefix 静态路径前缀
	StaticPrefix string `yaml:"static_prefix" json:"static_prefix" xml:"static_prefix"`
	// StaticDir 静态文件目录
	StaticDir string `yaml:"static_dir" json:"static_dir" xml:"static_dir"`
	// BodyLimit body文件大小限制. Limit can be specified as 4x or 4xB, where x is one of the multiple from K, M, G, T or P.
	BodyLimit string `yaml:"body_limit" json:"body_limit" xml:"body_limit"`
	// TemplatePattern 视图模板渲染文件路径
	TemplatePattern string `yaml:"template_pattern" json:"template_pattern" xml:"template_pattern"`
}

type Template

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

func (*Template) Render

func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error

Jump to

Keyboard shortcuts

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