httpserver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: AGPL-3.0 Imports: 23 Imported by: 32

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

func MaxRequestBodySize(h echo.Handler) echo.HandlerFunc

func ProcessError

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

func Transaction

func Transaction() echo.MiddlewareFunc

Types

type HTTPServer

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

	// for web framework
	StaticOptions *middleware.StaticOptions
	StaticMW      echo.MiddlewareFunc

	DefaultTemplateDir   string // 模板路径默认值
	DefaultAssetsDir     string // 素材路径默认值
	DefaultAssetsURLPath 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{}
	// 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) 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) SetNavigate

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

func (*HTTPServer) SetPrefix

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

func (*HTTPServer) SetRouter

func (h *HTTPServer) SetRouter(router route.IRegister) *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