httpserver

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: AGPL-3.0 Imports: 25 Imported by: 25

Documentation

Index

Constants

View Source
const (
	KindBackend  = `backend`
	KindFrontend = `frontend`
)

Variables

View Source
var (
	Backend = New(KindBackend).
			SetRouter(route.NewRegister(defaults.Default).AddGroupNamer(groupNamer)).
			SetNavigate(navigate.NewProjectNavigates(`nging`))
	Frontend = New(KindFrontend).SetNavigate(navigate.NewProjectNavigates(`webx`))
	Servers  = &HTTPServers{
		Backend:  Backend,
		Frontend: Frontend,
	}
)
View Source
var (
	EmptyURL = &url.URL{}
)
View Source
var ErrorProcessors = []render.ErrorProcessor{
	func(ctx echo.Context, err error) (processed bool, newErr error) {
		if errors.Is(err, db.ErrNoMoreRows) {
			return true, echo.NewError(ctx.T(`数据不存在`), code.DataNotFound)
		}
		return false, err
	},
}

Functions

func Clear

func Clear()

func ErrorPageFunc

func ErrorPageFunc(c echo.Context) error

func FixedUploadURLPrefix added in v0.3.14

func FixedUploadURLPrefix() echo.MiddlewareFuncd

func HostChecker added in v0.3.1

func HostChecker(key string) echo.MiddlewareFuncd

func MaxRequestBodySize

func MaxRequestBodySize(h echo.Handler) echo.HandlerFunc

func ProcessError

func ProcessError(ctx echo.Context, err error) error

func SearchEngineNoindex added in v0.3.15

func SearchEngineNoindex() echo.MiddlewareFuncd

func Transaction

func Transaction() echo.MiddlewareFunc

func TrimPathSuffix added in v0.3.1

func TrimPathSuffix(ignorePrefixes ...string) echo.MiddlewareFuncd

Types

type HTTPServer

type HTTPServer struct {
	Name      string
	Navigate  *navigate.ProjectNavigates
	Router    route.IRegister
	Dashboard *dashboard.Dashboard
	Template  *ntemplate.Template
	TmplMgr   driver.Manager

	// for web framework
	StaticOptions         *middleware.StaticOptions
	StaticMW              echo.MiddlewareFunc
	KeepExtensionPrefixes []string
	RouteDefaultExtension string
	DefaultTemplateDir    string // 模板路径默认值
	DefaultAssetsDir      string // 素材路径默认值
	DefaultAssetsURLPath  string // 素材网址路径默认值
	DefaultStaticRootURL  string
	StaticRootURLPath     string
	TemplateDir           string                                   //模板文件夹
	AssetsDir             string                                   //素材文件夹
	AssetsURLPath         string                                   //素材网址路径
	DefaultAvatarURL      string                                   //默认头像网址
	RendererDo            func(driver.Driver)                      //模板引擎配置函数
	TmplCustomParser      func(tmpl string, content []byte) []byte //模板自定义解析函数
	ParseStrings          map[string]string                        //模板内容替换
	ParseStringFuncs      map[string]func() string                 //模板内容替换函数
	Middlewares           []interface{}
	GlobalFuncMap         map[string]interface{}
	FuncSetters           []func(echo.Context) error
	HostCheckerRegexpKey  string
	// contains filtered or unexported fields
}

func New

func New(kind string) *HTTPServer

func (*HTTPServer) Apply

func (h *HTTPServer) Apply()

func (*HTTPServer) Clear

func (h *HTTPServer) Clear()

func (*HTTPServer) GetStaticMW added in v0.3.3

func (h *HTTPServer) GetStaticMW() echo.MiddlewareFunc

func (*HTTPServer) I18n

func (h *HTTPServer) I18n() *language.Language

func (*HTTPServer) Prefix

func (h *HTTPServer) Prefix() string

func (*HTTPServer) Renderer

func (h *HTTPServer) Renderer() driver.Driver

func (*HTTPServer) SetKeepExtensionPrefixes added in v0.3.1

func (h *HTTPServer) SetKeepExtensionPrefixes(keepExtensionPrefixes []string) *HTTPServer

func (*HTTPServer) SetNavigate

func (h *HTTPServer) SetNavigate(nav *navigate.ProjectNavigates) *HTTPServer

func (*HTTPServer) SetPrefix

func (h *HTTPServer) SetPrefix(prefix string) *HTTPServer

func (*HTTPServer) SetRenderDataWrapper added in v0.3.1

func (h *HTTPServer) SetRenderDataWrapper(dataWrapper echo.DataWrapper) *HTTPServer

func (*HTTPServer) SetRouter

func (h *HTTPServer) SetRouter(router route.IRegister) *HTTPServer

func (*HTTPServer) SetTmplCustomParser added in v0.3.1

func (h *HTTPServer) SetTmplCustomParser(parser func(tmpl string, content []byte) []byte) *HTTPServer

type HTTPServers

type HTTPServers struct {
	Backend  *HTTPServer
	Frontend *HTTPServer
}

func (*HTTPServers) Clear

func (a *HTTPServers) Clear()

Jump to

Keyboard shortcuts

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