nvwa

package module
v0.0.0-...-8c26409 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: BSD-3-Clause Imports: 27 Imported by: 0

README

nuwa

用于带有管理后台类功能开发的基础套件,集成了功能:

  • i18n
  • 登录校验

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithUser

func ContextWithUser(ctx context.Context, user *User) context.Context

Types

type Dashboard

type Dashboard struct {
	PathPrefix    string        // uri 地址前缀,若为空,则默认为 /admin/
	AssetPrefix   string        // 静态资源地址前缀,若为空,则默认为 /asset/
	RegisterAsset string        // 在 PathPrefix 下注册 asset 的目录名,若有值则会注册
	Bundle        *xi18n.Bundle // 国际化资源,可选

	FuncMap template.FuncMap // 可选,注册到模版中的自定义方法

	SecretKey string // 加密秘钥,必填

	TemplateFS fs.FS // 模版文件,必填

	Router *xhttp.Router // 路由,可选

	UserFinder     func(ctx context.Context, name string) (*User, error)                                // 操作用户,必填
	UserCheckLogin func(ctx context.Context, req *http.Request, name string, psw string) (*User, error) // 用户登录,必填
	// contains filtered or unexported fields
}
func (db *Dashboard) AbsLink(uri string) string

func (*Dashboard) GetAssetPrefix

func (db *Dashboard) GetAssetPrefix() string

func (*Dashboard) GetPathPrefix

func (db *Dashboard) GetPathPrefix() string

func (*Dashboard) HTTPRouter

func (db *Dashboard) HTTPRouter() *xhttp.Router

func (*Dashboard) InitOnce

func (db *Dashboard) InitOnce()

func (*Dashboard) Render

func (db *Dashboard) Render(ctx context.Context, w http.ResponseWriter, req *http.Request, fileName string, data map[string]any)

Render 渲染外部注册资源的模版文件

func (*Dashboard) RenderWithLayout

func (db *Dashboard) RenderWithLayout(ctx context.Context, w http.ResponseWriter, req *http.Request, fileName string, data map[string]any)

RenderWithLayout 渲染外部注册资源的模版文件,然后将内容渲染到模版文件

func (*Dashboard) ServeHTTP

func (db *Dashboard) ServeHTTP(w http.ResponseWriter, req *http.Request)

type User

type User struct {
	Username string
	AuthCode string // 登录校验码,由 Password + Salt 等计算而得
	Disabled bool
	Raw      any
}

func UserFormContext

func UserFormContext(ctx context.Context) *User

Jump to

Keyboard shortcuts

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