webbase

package
v1.3.2-0...-4312943 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	web.Base
}

Base defines the web handler module.

func NewBase

func NewBase(traced bool) Base

NewBase returns a new web handler module.

func (*Base) Handler

func (w *Base) Handler(
	tmpl string,
	dataGetter func(*gin.Context) (interface{}, *Error),
) gin.HandlerFunc

Handler returns a gin handler rendering tmpl with data from dataGetter and 200 status code.

func (*Base) ServeErr

func (w *Base) ServeErr(ctx *gin.Context, err *Error)

ServeErr serves a html err page.

func (*Base) UnAuthHandler

func (w *Base) UnAuthHandler(tmpl string,
	dataGetter func(*gin.Context) (interface{}, *Error),
) gin.HandlerFunc

UnAuthHandler returns a gin handler rendering tmpl with data from dataGetter and 401 status code.

type Data

type Data struct {
	Title      string
	BinVersion string
	Ctx        struct {
		Org, User   string
		LoggedIn    bool
		AuthEnabled bool
	}
}

Data defines the base data.

func NewData

func NewData(title string, ginctx *gin.Context) Data

NewData returns a database.

type Error

type Error struct {
	StatusCode int
	Messages   []string
	Log        string
}

Error defines the web error.

type ErrorPage

type ErrorPage struct {
	Data
	StatusCode  int
	ErrTitle    string
	Description string
}

ErrorPage defines the data for error.html template.

func NewErrorPage

func NewErrorPage(ctx *gin.Context) ErrorPage

NewErrorPage returns error page data.

Jump to

Keyboard shortcuts

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