appsmodel

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: GPL-3.0 Imports: 6 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWebservice

func NewWebservice(w *Webservice)

NewWebservice initializes a new instance of the Webservice struct and assigns it to the global variable ws.

Parameters: - w: a pointer to a Webservice struct.

func SetRootDir

func SetRootDir(dir string)

SetRootDir sets the root directory of the Webservice.

Parameters:

dir (string): The new root directory.

Returns: None.

Types

type Configuration

type Configuration struct {
	Port     int    `yaml:"port"`
	Title    string `yaml:"title"`
	Favicon  string `yaml:"favicon"`
	Database struct {
		Name     string `yaml:"name"`
		Server   string `yaml:"server"`
		UserName string `yaml:"username"`
		Password string `yaml:"password"`
		Port     int    `yaml:"port"`
	} `yaml:"database"`
	Cookie struct {
		Persist  bool   `yaml:"persist"`
		Secure   bool   `yaml:"secure"`
		LifeTime int    `yaml:"lifetime"`
		SameSite string `yaml:"samesite"`
		Path     string `yaml:"path"`
	} `yaml:"cookie"`
	Template struct {
		Cached  bool     `yaml:"cached"`
		Dir     string   `yaml:"dir"`
		Options []string `yaml:"options"`
	} `yaml:"template"`
	Application struct {
		PageDir    string `yaml:"pagedir"`
		ContentDir string `yaml:"contentdir"`
		Setup      any
	} `yaml:"application"`
	Logging struct {
		Enabled bool `yaml:"enabled"`
	} `yaml:"logging"`
	ShowServerError bool `yaml:"showservererror"`
	HitTest         bool `yaml:"hittest"`
	ConfigPath      string
}

type Device

type Device struct {
	Type  dwtpl.DeviceType
	Model string
	OS    string
}

type Form added in v1.2.2

type Form struct {
	url.Values
	Errors formerrors
}

func NewForm added in v1.2.2

func NewForm(values url.Values) *Form

New creates a new Form with the provided values.

values: The form values to initialize the Form. Returns a pointer to the newly created Form.

func (*Form) Has added in v1.2.2

func (f *Form) Has(field string) bool

Has checks if a form field exists and returns a boolean value indicating whether the field is present or not.

Parameters: - field: a string representing the name of the form field to check.

Returns: - bool: true if the field is present in the form, false otherwise.

func (*Form) Needs added in v1.2.2

func (f *Form) Needs(field string)

func (*Form) Requires added in v1.2.2

func (f *Form) Requires(fields ...string)

func (*Form) Valid added in v1.2.2

func (f *Form) Valid() bool

type FormError added in v1.2.2

type FormError struct {
	FieldName string
	Message   string
}

type KeyName

type KeyName string
const DeviceKeyName KeyName = "device"
const IsAuthenticatedKeyName KeyName = "isauthenticated"
const PageVariableKeyName KeyName = "pagevariable"
const UserFullNameKeyName KeyName = "userfullname"
const UserIdKeyName KeyName = "userid"
const UserNickNameKeyName KeyName = "usernickname"

type PageVariable

type PageVariable struct {
	PageName         string
	Title            string
	HttpErrorNumber  int
	HttpErrorMessage string
	Form             *Form
	Setup            any
	Data             any
	MidleWares       *[]PageVariableMidleware
	CsrfToken        string
	Request          *http.Request
	Response         http.ResponseWriter
	UserId           string
	UserNickName     string
	UserFullName     string
	IsAuthenticated  bool
}

func (*PageVariable) Use added in v1.2.0

func (pv *PageVariable) Use(mw PageVariableMidleware)

type PageVariableMidleware added in v1.2.0

type PageVariableMidleware func(pv *PageVariable, pg *dwtpl.PageConfig) error

type Webservice

type Webservice struct {
	RootDir           string
	Configuration     *Configuration
	Mux               *chi.Mux
	TplMgr            *dwtpl.TemplateManager
	AllowedAsset      map[string]*[]string
	CurrentWsDir      string
	ShowServerError   bool
	Session           *scs.SessionManager
	ApplicationConfig any
	ApplicationData   any
}

func GetWebservice

func GetWebservice() *Webservice

GetWebservice returns the global instance of the Webservice struct.

No parameters. Returns a pointer to a Webservice struct.

Jump to

Keyboard shortcuts

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