remotewidgethelper

package
v1.11.4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilesKey = "Files"
)

Variables

View Source
var Registerers []Registerer

Functions

func AsFloat64

func AsFloat64(value any) (float64, error)

func AsMap

func AsMap(value any) (gin.H, error)

func AsSlice

func AsSlice(value any) ([]any, error)

func AsString

func AsString(value any) (string, error)

func AsUint64

func AsUint64(value any) (uint64, error)

func GetBaseUrl

func GetBaseUrl(levelToErase uint8, data gin.H) (string, error)

func GetCurrentUserId

func GetCurrentUserId(data gin.H) (uint64, error)

func GetFiles

func GetFiles(data gin.H) (map[string][]byte, error)

func GetFormData

func GetFormData(data gin.H) (gin.H, error)

func GetPagination

func GetPagination(defaultPageSize uint64, data gin.H) (uint64, uint64, uint64, string)

func GetPaginationNames

func GetPaginationNames() []string

Types

type Action

type Action struct {
	Kind       uint8
	Path       string
	QueryNames []string
	Handler    ActionHandler
}

type ActionHandler

type ActionHandler = func(context.Context, gin.H) (string, string, []byte, error)

type Widget

type Widget map[string]Action

func (Widget) AddAction

func (w Widget) AddAction(actionName string, kind uint8, path string, handler ActionHandler)

based on gin path convention, with the path "/view/:id/:name" the map passed to handler will contains "pathData/id" and "pathData/name" entries handler returned values are supposed to be redirect, templateName and data :

  1. redirect is a redirect path (ignored if empty), to build an absolute one on the site the map contains the "CurrentUrl" entry

  2. data could be :

    - a json marshalled map which entries will be added to the data passed to the template engine with templateName

    - or any raw data when the action kind is remoteservice.KIND_RAW

func (Widget) AddActionWithQuery

func (w Widget) AddActionWithQuery(actionName string, kind uint8, path string, queryNames []string, handler ActionHandler)

Like AddAction but allow to indicate which query parameters should be transmitted.

type WidgetManager

type WidgetManager map[string]Widget

func NewManager

func NewManager() WidgetManager

func (WidgetManager) CreateWidget

func (manager WidgetManager) CreateWidget(widgetName string) Widget

Jump to

Keyboard shortcuts

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