Documentation
¶
Overview ¶
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func Auto() echo.MiddlewareFunc
- func Del(key string)
- func EmptyRouteUsingDefaultRender(c echo.Context) bool
- func ErrorHTMLTemplate(_ string) ([]byte, error)
- func HTTPErrorHandler(opt *Options) echo.HTTPErrorHandler
- func Middleware(d echo.Renderer) echo.MiddlewareFunc
- func New(key string, tmplDir string, args ...logger.Logger) Driver
- func Reg(key string, val func(string) Driver)
- type Config
- func (t *Config) AddFuncSetter(set ...echo.HandlerFunc) *Config
- func (t *Config) AddRendererDo(rd ...func(driver.Driver)) *Config
- func (t *Config) ApplyTo(e *echo.Echo, manager ...driver.Manager) *Config
- func (t *Config) HTTPErrorHandler() echo.HTTPErrorHandler
- func (t *Config) MakeRenderer(manager ...driver.Manager) driver.Driver
- func (t *Config) NewRenderer(manager ...driver.Manager) driver.Driver
- func (t *Config) Parser() func(tmpl string, content []byte) []byte
- func (t *Config) Renderer() driver.Driver
- func (t *Config) SetFuncSetter(set ...echo.HandlerFunc) *Config
- func (t *Config) SetRendererDo(rd ...func(driver.Driver)) *Config
- func (t *Config) StaticMiddleware() interface{}
- func (t *Config) ThemeDir(args ...string) string
- type ErrorProcessor
- type Options
- func (opt *Options) AddErrorProcessor(h ...ErrorProcessor) *Options
- func (opt *Options) AddFuncSetter(set ...echo.HandlerFunc) *Options
- func (opt *Options) GenTmplGetter() func(code int) string
- func (opt *Options) SetDefaultRender(renderer func(c echo.Context, data echo.H, code int) ([]byte, error)) *Options
- func (opt *Options) SetErrorProcessor(h ...ErrorProcessor) *Options
- func (opt *Options) SetFuncSetter(set ...echo.HandlerFunc) *Options
Constants ¶
This section is empty.
Variables ¶
var DefaultFuncMapSkipper = func(c echo.Context) bool { return c.Format() != echo.ContentTypeHTML && !c.IsAjax() && !c.IsPjax() }
var ( DefaultOptions = &Options{ Skipper: echo.DefaultSkipper, ErrorPages: make(map[int]string), DefaultHTTPErrorCode: http.StatusInternalServerError, SetFuncMap: []echo.HandlerFunc{}, DefaultRenderer: defaultRender, UsingDefaultRenderer: usingDefaultRender, } )
Functions ¶
func Auto ¶ added in v1.3.7
func Auto() echo.MiddlewareFunc
func EmptyRouteUsingDefaultRender ¶ added in v1.21.6
EmptyRouteUsingDefaultRender checks if the current route is empty and uses the default renderer.
func ErrorHTMLTemplate ¶ added in v1.21.1
func HTTPErrorHandler ¶ added in v1.1.0
func HTTPErrorHandler(opt *Options) echo.HTTPErrorHandler
HTTPErrorHandler returns a HTTP error handler that renders error pages based on the provided options.
Types ¶
type Config ¶ added in v1.1.0
type Config struct {
// TmplDir is the directory where templates are stored.
TmplDir string
// Theme is the name of the theme to be used for rendering templates.
Theme string
// Engine is the name of the template engine to be used for rendering templates.
Engine string
// Style is the name of the style to be used for rendering templates.
Style string
// Reload indicates whether the templates should be reloaded on each modify.
Reload bool
// ParseStrings is a map of strings to be replaced in the template content.
ParseStrings map[string]string
// ParseStringFuncs is a map of functions that return strings to be replaced in the template content.
ParseStringFuncs map[string]func() string
StaticOptions *middleware.StaticOptions
Debug bool
FuncMapGlobal map[string]interface{}
RendererDo []func(driver.Driver)
CustomParser func(tmpl string, content []byte) []byte
// ErrorPages defines the error pages to be used for specific HTTP error codes.
ErrorPages map[int]string
// DefaultHTTPErrorCode is the default HTTP error code to use when no specific error code is provided.
DefaultHTTPErrorCode int
// ErrorProcessors defines a list of error processors that can be used to handle errors.
ErrorProcessors []ErrorProcessor
// ErrorCodeLinks defines a mapping of error codes to links that can be used to provide additional information about the error.
ErrorCodeLinks map[code.Code]echo.KVList
// DefaultRenderer is a function that can be used to render the default response for an error.
DefaultRenderer func(c echo.Context, data echo.H, code int) ([]byte, error)
// UsingDefaultRenderer is a function that can be used to determine if the default renderer should be used.
UsingDefaultRenderer func(echo.Context) bool
// contains filtered or unexported fields
}
func (*Config) AddFuncSetter ¶ added in v1.3.9
func (t *Config) AddFuncSetter(set ...echo.HandlerFunc) *Config
func (*Config) AddRendererDo ¶ added in v1.4.3
func (*Config) HTTPErrorHandler ¶ added in v1.6.0
func (t *Config) HTTPErrorHandler() echo.HTTPErrorHandler
func (*Config) MakeRenderer ¶ added in v1.6.0
func (*Config) NewRenderer ¶ added in v1.1.1
NewRenderer 新建渲染接口
func (*Config) SetFuncSetter ¶ added in v1.3.9
func (t *Config) SetFuncSetter(set ...echo.HandlerFunc) *Config
func (*Config) SetRendererDo ¶ added in v1.4.3
func (*Config) StaticMiddleware ¶ added in v1.6.0
func (t *Config) StaticMiddleware() interface{}
type ErrorProcessor ¶ added in v1.6.0
type Options ¶ added in v1.1.1
type Options struct {
Skipper echo.Skipper
ErrorPages map[int]string
ErrorProcessors []ErrorProcessor
ErrorCodeLinks map[code.Code]echo.KVList
DefaultHTTPErrorCode int
SetFuncMap []echo.HandlerFunc
DefaultRenderer func(c echo.Context, data echo.H, code int) ([]byte, error)
UsingDefaultRenderer func(echo.Context) bool
}
func (*Options) AddErrorProcessor ¶ added in v1.6.0
func (opt *Options) AddErrorProcessor(h ...ErrorProcessor) *Options
func (*Options) AddFuncSetter ¶ added in v1.3.9
func (opt *Options) AddFuncSetter(set ...echo.HandlerFunc) *Options
func (*Options) GenTmplGetter ¶ added in v1.21.2
func (*Options) SetDefaultRender ¶ added in v1.21.3
func (*Options) SetErrorProcessor ¶ added in v1.6.0
func (opt *Options) SetErrorProcessor(h ...ErrorProcessor) *Options
func (*Options) SetFuncSetter ¶ added in v1.3.9
func (opt *Options) SetFuncSetter(set ...echo.HandlerFunc) *Options