httpserver

package
v0.6.26 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: AGPL-3.0 Imports: 25 Imported by: 25

Documentation

Index

Constants

View Source
const (
	KindBackend  = `backend`
	KindFrontend = `frontend`
)
View Source
const (
	MetaKeyPermission = `permission`
	PermissionPublic  = `public` // 所有登录用户
	PermissionGuest   = `guest`  // 匿名
)

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 GuestHandler added in v0.6.13

func GuestHandler(r route.IRegister, h interface{}, meta ...echo.H) echo.Handler

func HostChecker added in v0.3.1

func HostChecker(key string) echo.MiddlewareFuncd

func MaxRequestBodySize

func MaxRequestBodySize(h echo.Handler) echo.HandlerFunc

func PermGuestKV added in v0.6.13

func PermGuestKV() (string, string)

func PermPublicKV added in v0.6.13

func PermPublicKV() (string, string)

func ProcessError

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

func PublicHandler added in v0.6.13

func PublicHandler(r route.IRegister, h interface{}, meta ...echo.H) echo.Handler

func SearchEngineNoindex added in v0.3.15

func SearchEngineNoindex() echo.MiddlewareFuncd

func SetGroupMetaPermissionGuest added in v0.6.13

func SetGroupMetaPermissionGuest(s GroupSetMetaKV) *echo.Group

func SetGroupMetaPermissionPublic added in v0.6.13

func SetGroupMetaPermissionPublic(s GroupSetMetaKV) *echo.Group

func SetMetaPermissionGuest added in v0.6.13

func SetMetaPermissionGuest(s RouteSetMetaKV) echo.IRouter

func SetMetaPermissionPublic added in v0.6.13

func SetMetaPermissionPublic(s RouteSetMetaKV) echo.IRouter

func Transaction

func Transaction() echo.MiddlewareFunc

func TrimPathSuffix added in v0.3.1

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

Types

type GroupSetMetaKV added in v0.6.13

type GroupSetMetaKV interface {
	SetMetaKV(string, interface{}) *echo.Group
}

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) GuestHandler added in v0.6.13

func (h *HTTPServer) GuestHandler(handler interface{}, meta ...echo.H) echo.Handler

func (*HTTPServer) I18n

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

func (*HTTPServer) Prefix

func (h *HTTPServer) Prefix() string

func (*HTTPServer) PublicHandler added in v0.6.13

func (h *HTTPServer) PublicHandler(handler interface{}, meta ...echo.H) echo.Handler

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

type RouteSetMetaKV added in v0.6.13

type RouteSetMetaKV interface {
	SetMetaKV(string, interface{}) echo.IRouter
}

Jump to

Keyboard shortcuts

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