app

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendBinding

func AppendBinding(bb []apps.Binding, b *apps.Binding) []apps.Binding

Types

type App

type App struct {
	Logger utils.Logger
	Router *mux.Router
	Icon   string
}

func NewApp

func NewApp(r *mux.Router, log utils.Logger) *App

func (*App) HandleCall

func (a *App) HandleCall(p string, h HandlerFunc)

func (*App) HandleCommand

func (a *App) HandleCommand(command Command)

func (App) WithIcon

func (a App) WithIcon(iconPath string) *App

func (*App) WithManifest

func (a *App) WithManifest(m apps.Manifest) *App

func (*App) WithStatic

func (a *App) WithStatic(staticFS fs.FS) *App

type AppConfig

type AppConfig struct {
	PonosURL string `json:"ponos_url"`
	Token    string `json:"token"`
}

AppConfig the config of the app

func (AppConfig) Validate

func (a AppConfig) Validate() error

type CallRequest

type CallRequest struct {
	apps.CallRequest

	App       App
	GoContext context.Context
	// contains filtered or unexported fields
}

func (CallRequest) AppProxyURL

func (creq CallRequest) AppProxyURL(paths ...string) string

func (CallRequest) AppendDebugJSON

func (creq CallRequest) AppendDebugJSON(in []apps.Field) []apps.Field

func (CallRequest) AsActingUser

func (creq CallRequest) AsActingUser() *appclient.Client

func (CallRequest) AsBot

func (creq CallRequest) AsBot() *appclient.Client

func (CallRequest) BoolValue

func (creq CallRequest) BoolValue(name string) (value, found bool)

func (CallRequest) DeleteAppConfig

func (creq CallRequest) DeleteAppConfig() error

DeleteAppConfig deletes the config of the app from KV store

func (CallRequest) GetAppConfig

func (creq CallRequest) GetAppConfig() (*AppConfig, error)

GetAppConfig return store the config of the app from KV store

func (CallRequest) GetUserAccess

func (creq CallRequest) GetUserAccess() (*UsersAccess, error)

GetUserAccess returns the user access config from KV store

func (CallRequest) GetValue

func (creq CallRequest) GetValue(name, defaultValue string) string

GetValue scans Values, then State if it is a map for a name, returns the value, or the default if not found.

func (CallRequest) Respond

func (creq CallRequest) Respond(message string, v interface{}) apps.CallResponse

func (CallRequest) StoreAppConfig

func (creq CallRequest) StoreAppConfig(cfg *AppConfig) error

StoreAppConfig store the config of the app in KV store

func (CallRequest) StoreUserAccess

func (creq CallRequest) StoreUserAccess(userID string) error

StoreUserAccess stores the user access config in KV store

func (CallRequest) StringValue

func (creq CallRequest) StringValue(name string) (string, bool)

type Command

type Command struct {
	Name        string
	Hint        string
	Description string
	Icon        string
	BaseSubmit  *apps.Call
	BaseForm    *apps.Form

	Handler func(CallRequest) apps.CallResponse
}

func (Command) Binding

func (c Command) Binding(creq CallRequest) apps.Binding

func (Command) Form

func (c Command) Form(creq CallRequest) *apps.Form

func (Command) Path

func (c Command) Path() string

func (Command) Submit

func (c Command) Submit(creq CallRequest) *apps.Call

type HandlerFunc

type HandlerFunc func(CallRequest) apps.CallResponse

func CallHandler

func CallHandler(h func(CallRequest) (string, error)) HandlerFunc

func FormHandler

func FormHandler(h func(CallRequest) (apps.Form, error)) HandlerFunc

func LookupHandler

func LookupHandler(h func(CallRequest) []apps.SelectOption) HandlerFunc

func RequireAdmin

func RequireAdmin(h HandlerFunc) HandlerFunc

func RequireConnectedUsers

func RequireConnectedUsers(h HandlerFunc) HandlerFunc

type UsersAccess

type UsersAccess struct {
	UserIDS []string `json:"user_ids"`
}

UsersAccess the users can use the app

func (*UsersAccess) IsAllowed

func (ua *UsersAccess) IsAllowed(userID string) bool

IsAllowed if user allowed

Jump to

Keyboard shortcuts

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