prago

package module
v0.0.0-...-6b79da1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 52 Imported by: 0

README

Prago - simple Go framework

Prago is simple web framework fo Go language I am using for my projects.

https://www.odchazel.com

Documentation

Overview

Package prago is MVC framework for go

Index

Constants

This section is empty.

Variables

View Source
var ErrItemNotFound = errors.New("item not found")

ErrItemNotFound is returned when no item is found

View Source
var ErrWrongWhereFormat = errors.New("wrong where format")

ErrWrongWhereFormat is returned when where query has a bad format

Functions

func Cached

func Cached[T any](app *App, name string, createFn func() T) chan T

func CreateItem

func CreateItem[T any](app *App, item *T) error

func CreateItemWithContext

func CreateItemWithContext[T any](ctx context.Context, app *App, item *T) error

func CreateWithLog

func CreateWithLog[T any](item *T, request *Request) error

func DeleteItem

func DeleteItem[T any](app *App, id int64) error

func DeleteItemWithContext

func DeleteItemWithContext[T any](ctx context.Context, app *App, id int64) error

func DeleteWithLog

func DeleteWithLog[T any](item *T, request *Request) error

func PreviewURLFunction

func PreviewURLFunction[T any](app *App, fn func(*T) string)

func Replace

func Replace[T any](ctx context.Context, app *App, item *T) error

func UpdateItem

func UpdateItem[T any](app *App, item *T) error

func UpdateItemWithContext

func UpdateItemWithContext[T any](ctx context.Context, app *App, item *T) error

func UpdateWithLog

func UpdateWithLog[T any](item *T, request *Request) error

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func ResourceAPI

func ResourceAPI[T any](app *App, url string) *API

func (*API) Handler

func (api *API) Handler(handler func(*Request)) *API

func (*API) HandlerJSON

func (api *API) HandlerJSON(handler func(*Request) interface{}) *API

func (*API) Method

func (api *API) Method(method string) *API

func (*API) Permission

func (api *API) Permission(permission Permission) *API

type Action

type Action struct {
	// contains filtered or unexported fields
}

Action represents action

func ResourceAction

func ResourceAction[T any](app *App, url string) *Action

func ResourceFormAction

func ResourceFormAction[T any](app *App, url string, formGenerator func(*Form, *Request), validation Validation) *Action

func ResourceFormItemAction

func ResourceFormItemAction[T any](
	app *App,
	url string,
	formGenerator func(*T, *Form, *Request),
	validation func(*T, ValidationContext),
) *Action

func ResourceItemHandler

func ResourceItemHandler[T any](app *App, url string, fn func(*T, *Request)) *Action

func ResourceItemView

func ResourceItemView[T any](app *App, url string, template string, dataSource func(*T, *Request) interface{}) *Action

func (*Action) Board

func (action *Action) Board(board *Board) *Action

func (*Action) Handler

func (action *Action) Handler(handler func(*Request)) *Action

func (*Action) Icon

func (action *Action) Icon(icon string) *Action

func (*Action) Method

func (action *Action) Method(method string) *Action

Method sets action method (GET, POST, PUT or DELETE)

func (*Action) Name

func (action *Action) Name(name func(string) string) *Action

Name sets action name

func (*Action) Permission

func (action *Action) Permission(permission Permission) *Action

Permission sets action permission

func (*Action) View

func (action *Action) View(template string, dataSource func(*Request) any) *Action

type Activity

type Activity struct {
	ID           int64
	ResourceID   string
	User         int64
	ActivityType string
}

type App

type App struct {
	UsersResource *Resource

	FilesResource *Resource

	MainBoard *Board
	// contains filtered or unexported fields
}

App is main struct of prago application

func New

func New(appName, version string) *App

New creates App structure for prago app

func (*App) API

func (app *App) API(url string) *API

func (*App) Action

func (app *App) Action(url string) *Action

AddAction adds action to root

func (*App) AddCustomSearchFunction

func (app *App) AddCustomSearchFunction(fn func(q string, userData UserData) []*CustomSearchResult)

func (*App) AddDevStaticFiles

func (app *App) AddDevStaticFiles(path string)

AddDevStaticFiles adds path for public files for development and publish them in server's root

func (*App) AddEnumFieldType

func (app *App) AddEnumFieldType(name string, items [][2]string)

AddEnumFieldType adds enum field type

func (*App) AddEnumFieldTypeLocalized

func (app *App) AddEnumFieldTypeLocalized(name string, items []FieldTypeEnum)

AddEnumFieldTypeLocalized adds localized enum field

func (*App) AddLessDevelopmentPaths

func (app *App) AddLessDevelopmentPaths(sourcePath, targetPath string)

AddLessDevelopmentPaths compiles less files in sourcePath into targetPath in development mode

func (*App) AddSassDevelopmentPaths

func (app *App) AddSassDevelopmentPaths(sourcePath, targetPath string)

func (*App) AddStaticFiles

func (app *App) AddStaticFiles(f fs.FS, pathPrefix string)

AddStaticFiles add filesystem of public files and publish them in server's root

func (*App) AddTemplateFunction

func (app *App) AddTemplateFunction(name string, f interface{})

AddTemplateFunction adds template function

func (*App) AddTemplates

func (app *App) AddTemplates(fsys fs.FS, patterns ...string) error

AddTemplates loads app's html templates from file system

func (*App) AddTemplatesDevelopmentPath

func (app *App) AddTemplatesDevelopmentPath(path string, patterns ...string)

AddTemplatesDevelopmentPath automatically compiles templates from path in development mode

func (*App) AddTypeScriptDevelopmentPath

func (app *App) AddTypeScriptDevelopmentPath(path string)

AddTypeScriptDevelopmentPath automatically runs compilation of .tsc file in development mode

func (*App) AfterAction

func (app *App) AfterAction(fn func(p *Request))

AddAfterAction adds action which is executed after main router action is called

func (*App) BeforeAction

func (app *App) BeforeAction(fn func(p *Request))

AddBeforeAction adds action which is executed before main router action is called

func (*App) ClearCache

func (app *App) ClearCache()

func (*App) DevelopmentMode

func (app *App) DevelopmentMode() bool

DevelopmentMode returns if app is running in development mode

func (*App) ElasticSearchClient

func (app *App) ElasticSearchClient() *pragelastic.Client

func (*App) Email

func (app *App) Email() *Email

func (*App) ExecuteTemplate

func (app *App) ExecuteTemplate(wr io.Writer, name string, data interface{}) error

ExecuteTemplate executes template

func (*App) ExecuteTemplateToString

func (app *App) ExecuteTemplateToString(templateName string, data interface{}) string

ExecuteTemplateToString executes template and return string, it panics

func (*App) FormAction

func (app *App) FormAction(url string, formGenerator func(*Form, *Request), validator Validation) *Action

func (*App) GetCachedUserEmail

func (app *App) GetCachedUserEmail(_ context.Context, id int64) string

func (*App) GetDB

func (app *App) GetDB() *sql.DB

func (*App) GetFiles

func (app *App) GetFiles(ctx context.Context, ids string) []*File

GetFiles gets files from app

func (*App) GetSetting

func (app *App) GetSetting(ctx context.Context, id string) (string, error)

func (*App) Handle

func (app *App) Handle(method, path string, action func(p *Request), constraints ...routerConstraint)

Get creates new route for GET request

func (*App) Icon

func (app *App) Icon(icon string) *App

func (*App) JavascriptPath

func (app *App) JavascriptPath(url string) *App

JavascriptPath adds javascript

func (*App) ListenActivity

func (app *App) ListenActivity(handler func(Activity))

ListenActivity listens to all changes in app's administration

func (*App) Log

func (app *App) Log() *logger

Log returns logger structure

func (app *App) Logo(logo []byte) *App

Logo sets application public path to logo

func (*App) Name

func (app *App) Name(name func(string) string) *App

Name sets localized human name to app

func (*App) NewBoard

func (app *App) NewBoard(url string) *Board

func (*App) Notification

func (app *App) Notification(name string) *Notification

Notification creates notification

func (*App) Permission

func (app *App) Permission(permission Permission) *App

Permission adds permission to admin

func (*App) Role

func (app *App) Role(role string, permissions []Permission) *App

Role adds role to admin

func (*App) Run

func (app *App) Run()

func (*App) SetIcons

func (app *App) SetIcons(iconsFS embed.FS, prefix string)

func (*App) SetLogHandler

func (app *App) SetLogHandler(fn func(string, string))

func (*App) Setting

func (app *App) Setting(id string, permission Permission) *Setting

func (*App) Table

func (app *App) Table() *Table

func (*App) UploadFile

func (app *App) UploadFile(ctx context.Context, fileHeader *multipart.FileHeader, request *Request, description string) (*File, error)

type Board

type Board struct {
	MainDashboard *Dashboard
	// contains filtered or unexported fields
}

func (*Board) Dashboard

func (board *Board) Dashboard(name func(string) string) *Dashboard

func (*Board) Icon

func (board *Board) Icon(icon string) *Board

func (*Board) IsMainBoard

func (board *Board) IsMainBoard() bool

func (*Board) Name

func (board *Board) Name(name func(string) string) *Board

type CustomSearchResult

type CustomSearchResult struct {
	URL      string
	Prename  string
	Name     string
	Priority int64
}

type Dashboard

type Dashboard struct {
	// contains filtered or unexported fields
}

func (*Dashboard) AddFormItemOptions

func (dashboard *Dashboard) AddFormItemOptions(id, name string, options [][2]string)

func (*Dashboard) AddTask

func (dashboard *Dashboard) AddTask(name func(string) string, permission Permission, handler func(*TaskActivity) error)

Task creates task

func (*Dashboard) Figure

func (dashboard *Dashboard) Figure(name func(string) string, permission Permission) *DashboardFigure

func (*Dashboard) Table

func (group *Dashboard) Table(tableFn func(*Request) *Table, permission Permission) *DashboardTable

type DashboardFigure

type DashboardFigure struct {
	// contains filtered or unexported fields
}

func (*DashboardFigure) Compare

func (item *DashboardFigure) Compare(value func(*Request) int64, description func(string) string) *DashboardFigure

func (*DashboardFigure) RefreshTime

func (figure *DashboardFigure) RefreshTime(seconds int64) *DashboardFigure

func (*DashboardFigure) URL

func (item *DashboardFigure) URL(url string) *DashboardFigure

func (*DashboardFigure) Unit

func (item *DashboardFigure) Unit(unit func(string) string) *DashboardFigure

func (*DashboardFigure) Value

func (item *DashboardFigure) Value(value func(*Request) int64) *DashboardFigure

type DashboardFigureData

type DashboardFigureData struct {
	Value       string
	Description string
	IsGreen     bool
	IsRed       bool
}

type DashboardFormItem

type DashboardFormItem struct {
	ID       string
	Name     string
	Template string
	Value    string
	Options  [][2]string
}

type DashboardTable

type DashboardTable struct {
	// contains filtered or unexported fields
}

func (*DashboardTable) RefreshTime

func (table *DashboardTable) RefreshTime(seconds int64) *DashboardTable

type Email

type Email struct {
	// contains filtered or unexported fields
}

func (*Email) Attachement

func (email *Email) Attachement(filename string, content []byte) *Email

func (*Email) From

func (email *Email) From(name, emailAddress string) *Email

func (*Email) HTMLContent

func (email *Email) HTMLContent(content string) *Email

func (*Email) Send

func (email *Email) Send() error

func (*Email) Subject

func (email *Email) Subject(subject string) *Email

func (*Email) TextContent

func (email *Email) TextContent(content string) *Email

func (*Email) To

func (email *Email) To(name, emailAddress string) *Email

type Field

type Field struct {
	// contains filtered or unexported fields
}

func (*Field) DBDescription

func (field *Field) DBDescription(description string) *Field

func (*Field) Description

func (field *Field) Description(description func(string) string) *Field

func (*Field) FormTemplate

func (field *Field) FormTemplate(template string) *Field

func (*Field) GetManuallySetPluralName

func (field *Field) GetManuallySetPluralName(locale string) string

func (*Field) Name

func (field *Field) Name(name func(string) string) *Field

func (*Field) ViewTemplate

func (field *Field) ViewTemplate(template string) *Field

type FieldTypeEnum

type FieldTypeEnum struct {
	ID   string
	Name func(string) string
}

FieldTypeEnum enum type of field

type File

type File struct {
	ID          int64     `prago-order-desc:"true" prago-preview:"true"`
	UID         string    `prago-unique:"true" prago-preview:"true" prago-type:"cdnfile"`
	Name        string    `prago-can-edit:"nobody"`
	Description string    `prago-type:"text" prago-preview:"true"`
	User        int64     `prago-type:"relation" prago-preview:"true" prago-can-edit:"nobody"`
	Width       int64     `prago-can-edit:"nobody" prago-preview:"true"`
	Height      int64     `prago-can-edit:"nobody" prago-preview:"true"`
	CreatedAt   time.Time `prago-preview:"true"`
	UpdatedAt   time.Time `prago-preview:"true"`
}

File is structure representing files in admin

func (*File) GetExactSize

func (f *File) GetExactSize(width, height int) string

GetSmall file path

func (File) GetExtension

func (f File) GetExtension() string

GetExtension gets file extension

func (*File) GetGiant

func (f *File) GetGiant() string

GetGiant file path

func (*File) GetLarge

func (f *File) GetLarge() string

GetLarge file path

func (*File) GetMedium

func (f *File) GetMedium() string

GetMedium file path

func (*File) GetMetadataPath

func (f *File) GetMetadataPath() string

GetMetadataPath gets metadada file path

func (*File) GetOriginal

func (f *File) GetOriginal() string

GetOriginal file path

func (*File) GetSmall

func (f *File) GetSmall() string

GetSmall file path

func (*File) IsImage

func (f *File) IsImage() bool

IsImage detects if file is image

type Form

type Form struct {
	Action                 string
	Icon                   string
	Title                  string
	Description            string
	Items                  []*FormItem
	Valid                  bool
	CSRFToken              string
	HTMLAfter              template.HTML
	AutosubmitFirstTime    bool
	AutosubmitOnDataChange bool
	// contains filtered or unexported fields
}

Form represents admin form

func NewForm

func NewForm(action string) *Form

NewForm creates new form

func (*Form) AddCAPTCHAInput

func (f *Form) AddCAPTCHAInput(name, description string) *FormItem

AddCAPTCHAInput to form

func (*Form) AddCSRFToken

func (form *Form) AddCSRFToken(request *Request) *Form

func (*Form) AddCheckbox

func (f *Form) AddCheckbox(name, description string) *FormItem

AddCheckbox to form

func (*Form) AddDatePicker

func (f *Form) AddDatePicker(name, description string) *FormItem

AddDatePicker to form

func (*Form) AddDateTimePicker

func (f *Form) AddDateTimePicker(name, description string) *FormItem

func (*Form) AddDeleteSubmit

func (f *Form) AddDeleteSubmit(description string) *FormItem

AddDeleteSubmit to form

func (*Form) AddEmailInput

func (f *Form) AddEmailInput(name, description string) *FormItem

AddEmailInput to form

func (*Form) AddFileInput

func (f *Form) AddFileInput(name, description string) *FormItem

AddFileInput to form

func (*Form) AddHidden

func (f *Form) AddHidden(name string) *FormItem

AddHidden to form

func (*Form) AddItem

func (f *Form) AddItem(item *FormItem)

AddItem adds form item

func (*Form) AddPasswordInput

func (f *Form) AddPasswordInput(name, description string) *FormItem

AddPasswordInput to form

func (*Form) AddRadio

func (f *Form) AddRadio(name, description string, values [][2]string) *FormItem

func (*Form) AddRelation

func (f *Form) AddRelation(name, description string, relatedResourceID string) *FormItem

func (*Form) AddSelect

func (f *Form) AddSelect(name, description string, values [][2]string) *FormItem

AddSelect to form

func (*Form) AddSubmit

func (f *Form) AddSubmit(description string) *FormItem

AddSubmit to form

func (*Form) AddTextInput

func (f *Form) AddTextInput(name, description string) *FormItem

AddTextInput to form

func (*Form) AddTextareaInput

func (f *Form) AddTextareaInput(name, description string) *FormItem

AddTextareaInput to form

func (*Form) BindData

func (f *Form) BindData(params url.Values)

BindData to form

func (*Form) GetBoxHeader

func (form *Form) GetBoxHeader() *boxHeader

type FormItem

type FormItem struct {
	ID          string
	Icon        string
	Name        string
	Description string
	Required    bool
	Focused     bool
	Readonly    bool
	HiddenName  bool
	Hidden      bool
	Template    string
	Value       string
	Data        interface{}
	UUID        string
	// contains filtered or unexported fields
}

FormItem represents item of form

func (*FormItem) AddUUID

func (f *FormItem) AddUUID()

AddUUID to form

type FormValidationError

type FormValidationError struct {
	Text string
}

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

func (*Graph) DataMap

func (g *Graph) DataMap(m map[string]float64) *Graph

func (*Graph) Name

func (g *Graph) Name(name string) *Graph

func (*Graph) View

func (graph *Graph) View() *graphDataView

type Notification

type Notification struct {
	// contains filtered or unexported fields
}

NotificationItem represents item for notification

func (*Notification) Flash

func (n *Notification) Flash(request *Request) error

func (*Notification) Push

func (n *Notification) Push(userID int64)

func (*Notification) SetDescription

func (n *Notification) SetDescription(description string) *Notification

SetDescription sets description to notification item

func (*Notification) SetImage

func (n *Notification) SetImage(image string) *Notification

func (*Notification) SetPreName

func (n *Notification) SetPreName(preName string) *Notification

SetPreName sets prefix name to notification item

func (*Notification) SetPrimaryAction

func (n *Notification) SetPrimaryAction(name string, fn func()) *Notification

func (*Notification) SetProgress

func (n *Notification) SetProgress(progress *float64) *Notification

SetProgress sets description to notification item

func (*Notification) SetSecondaryAction

func (n *Notification) SetSecondaryAction(name string, fn func()) *Notification

func (*Notification) SetStyleFail

func (n *Notification) SetStyleFail() *Notification

SetTypeFail sets notification item type to fail

func (*Notification) SetStyleSuccess

func (n *Notification) SetStyleSuccess() *Notification

SetTypeSuccess sets notification item type to success

func (*Notification) SetURL

func (n *Notification) SetURL(url string) *Notification

type Permission

type Permission string

Permission for access

type QueryData

type QueryData[T any] struct {
	// contains filtered or unexported fields
}

func Query

func Query[T any](app *App) *QueryData[T]

func (*QueryData[T]) Context

func (q *QueryData[T]) Context(ctx context.Context) *QueryData[T]

func (*QueryData[T]) Count

func (q *QueryData[T]) Count() (int64, error)

func (*QueryData[T]) Debug

func (q *QueryData[T]) Debug() *QueryData[T]

func (*QueryData[T]) First

func (q *QueryData[T]) First() *T

func (*QueryData[T]) ID

func (q *QueryData[T]) ID(id any) *T

func (*QueryData[T]) Is

func (q *QueryData[T]) Is(name string, value interface{}) *QueryData[T]

func (*QueryData[T]) Limit

func (q *QueryData[T]) Limit(limit int64) *QueryData[T]

func (*QueryData[T]) List

func (q *QueryData[T]) List() []*T

func (*QueryData[T]) Offset

func (q *QueryData[T]) Offset(offset int64) *QueryData[T]

func (*QueryData[T]) Order

func (q *QueryData[T]) Order(order string) *QueryData[T]

func (*QueryData[T]) OrderDesc

func (q *QueryData[T]) OrderDesc(order string) *QueryData[T]

func (*QueryData[T]) Where

func (q *QueryData[T]) Where(condition string, values ...interface{}) *QueryData[T]

type Request

type Request struct {
	Written          bool
	ResponseStatus   int
	ResponseTemplate string
	// contains filtered or unexported fields
}

Request represents structure for http request

func (*Request) AddFlashMessage

func (request *Request) AddFlashMessage(message string)

AddFlashMessage adds flash message to request

func (*Request) Authorize

func (request *Request) Authorize(permission Permission) bool

func (*Request) Locale

func (request *Request) Locale() string

func (*Request) Name

func (request *Request) Name() string

func (Request) Param

func (request Request) Param(name string) string

func (Request) Params

func (request Request) Params() url.Values

Params returns url.Values of request

func (*Request) Redirect

func (request *Request) Redirect(url string)

Redirect redirects request to new url

func (Request) Request

func (request Request) Request() *http.Request

Request returns underlying http.Request

func (Request) Response

func (request Request) Response() http.ResponseWriter

Response returns underlying http.ResponseWriter

func (*Request) UserID

func (request *Request) UserID() int64

UserID returns id of logged in user, returns 0 if no user is logged

func (*Request) WriteHTML

func (request *Request) WriteHTML(statusCode int, templateName string, data any)

WriteHTML renders HTML view with HTTP code

func (*Request) WriteJSON

func (request *Request) WriteJSON(statusCode int, data interface{})

WriteJSON renders JSON with HTTP code

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

func GetResource

func GetResource[T any](app *App) *Resource

func NewResource

func NewResource[T any](app *App) *Resource

func (*Resource) Board

func (resource *Resource) Board(board *Board) *Resource

func (*Resource) Dashboard

func (resource *Resource) Dashboard(name func(string) string) *Dashboard

func (*Resource) DeleteValidation

func (resource *Resource) DeleteValidation(validation Validation) *Resource

func (*Resource) Field

func (resource *Resource) Field(name string) *Field

func (*Resource) Icon

func (resource *Resource) Icon(icon string) *Resource

func (*Resource) ItemsPerPage

func (resource *Resource) ItemsPerPage(itemsPerPage int64) *Resource

func (*Resource) Name

func (resource *Resource) Name(singularName, pluralName func(string) string) *Resource

func (*Resource) PermissionCreate

func (resource *Resource) PermissionCreate(permission Permission) *Resource

func (*Resource) PermissionDelete

func (resource *Resource) PermissionDelete(permission Permission) *Resource

func (*Resource) PermissionExport

func (resource *Resource) PermissionExport(permission Permission) *Resource

func (*Resource) PermissionUpdate

func (resource *Resource) PermissionUpdate(permission Permission) *Resource

func (*Resource) PermissionView

func (resource *Resource) PermissionView(permission Permission) *Resource

func (*Resource) Validation

func (resource *Resource) Validation(validation Validation) *Resource

type Setting

type Setting struct {
	// contains filtered or unexported fields
}

func (*Setting) DefaultValue

func (setting *Setting) DefaultValue(defaultValue string) *Setting

func (*Setting) Name

func (setting *Setting) Name(name func(string) string) *Setting

func (*Setting) ValueChangeCallback

func (setting *Setting) ValueChangeCallback(fn func()) *Setting

type Table

type Table struct {
	// contains filtered or unexported fields
}

func (*Table) AddFooterText

func (t *Table) AddFooterText(text string)

func (*Table) ExecuteHTML

func (t *Table) ExecuteHTML() template.HTML

TODO execute right into response

func (*Table) ExportXLSX

func (t *Table) ExportXLSX(writer io.Writer) error

func (*Table) Graph

func (t *Table) Graph() *Graph

func (*Table) Header

func (table *Table) Header(items ...string) *Table

func (*Table) Row

func (table *Table) Row(items ...*TableCell) *Table

func (*Table) Table

func (table *Table) Table() *Table

type TableCell

type TableCell struct {
	// contains filtered or unexported fields
}

func Cell

func Cell(item interface{}) *TableCell

func (*TableCell) Button

func (cell *TableCell) Button(btn *TableCellButton) *TableCell

func (*TableCell) CSSClass

func (cell *TableCell) CSSClass(class string) *TableCell

func (*TableCell) Center

func (cell *TableCell) Center() *TableCell

func (*TableCell) Checkbox

func (cell *TableCell) Checkbox(name string, checked bool) *TableCell

func (*TableCell) Colspan

func (cell *TableCell) Colspan(i int64) *TableCell

func (*TableCell) DescriptionAfter

func (cell *TableCell) DescriptionAfter(description string) *TableCell

func (*TableCell) DescriptionBefore

func (cell *TableCell) DescriptionBefore(description string) *TableCell

func (*TableCell) Green

func (cell *TableCell) Green() *TableCell

func (*TableCell) Header

func (cell *TableCell) Header() *TableCell

func (*TableCell) Nowrap

func (cell *TableCell) Nowrap() *TableCell

func (*TableCell) Pre

func (cell *TableCell) Pre() *TableCell

func (*TableCell) Right

func (cell *TableCell) Right() *TableCell

func (*TableCell) Rowspan

func (cell *TableCell) Rowspan(i int64) *TableCell

func (*TableCell) URL

func (cell *TableCell) URL(link string) *TableCell

type TableCellButton

type TableCellButton struct {
	Name    string
	URL     string
	OnClick template.JS
}

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task represent some user task

type TaskActivity

type TaskActivity struct {
	// contains filtered or unexported fields
}

TaskActivity represents task activity

func (*TaskActivity) Description

func (ta *TaskActivity) Description(description string)

func (*TaskActivity) Progress

func (ta *TaskActivity) Progress(finishedSoFar, total int64)

type UserData

type UserData interface {
	Name() string
	Locale() string
	Authorize(Permission) bool
}

type Validation

type Validation func(ValidationContext)

type ValidationContext

type ValidationContext interface {
	Locale() string
	GetValue(key string) string
	GetValues(key string) []string
	AddError(err string)
	AddItemError(key, err string)
	Validation() *formValidation
	Valid() bool
	Request() *Request
	UserHasPermission(Permission) bool
	Context() context.Context
}

type Writer

type Writer[T any] struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter[T any](app *App, template string) *Writer[T]

func (*Writer[T]) After

func (w *Writer[T]) After(fn func(*Request, *T)) *Writer[T]

func (*Writer[T]) Before

func (w *Writer[T]) Before(fn func(*Request, *T)) *Writer[T]

func (*Writer[T]) GET

func (w *Writer[T]) GET(path string, handler func(*Request, *T), constraints ...routerConstraint)

func (*Writer[T]) POST

func (w *Writer[T]) POST(path string, handler func(*Request, *T), constraints ...routerConstraint)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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