controllers

package
v1.0.82 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const StatusError = "error"

StatusError used to represent errored request

View Source
const StatusInternalServerError = "internalservererror"

StatusInternalServerError used to represent unhandled exception request

View Source
const StatusSuccess = "success"

StatusSuccess used to represent success request

View Source
const StatusUnauthorized = "unauthorized"

StatusUnauthorized used to represent unauthorized request

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func(*Context)

Action is alias for func(*Connection) (interface{}, error)

type ActionsHandler

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

ActionsHandler used to mange callbacks for controllers

func (*ActionsHandler) RegisterAction

func (handler *ActionsHandler) RegisterAction(actionName string, action Action)

RegisterAction used to register action

func (*ActionsHandler) RegisterBeforeActionHook added in v1.0.8

func (handler *ActionsHandler) RegisterBeforeActionHook(hook Hook, onlys []string)

RegisterBeforeActionHook used to add before hook

func (*ActionsHandler) RegisterConnectedAction

func (handler *ActionsHandler) RegisterConnectedAction(action Action)

RegisterConnectedAction used to register connected action

func (*ActionsHandler) RegisterDisconnectedAction

func (handler *ActionsHandler) RegisterDisconnectedAction(action Action)

RegisterDisconnectedAction used to register disconnected action

func (*ActionsHandler) RegisterErrorAction

func (handler *ActionsHandler) RegisterErrorAction(action Action)

RegisterErrorAction used to register error action

type Context

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

Context used to represent context with properties and params

func (*Context) Join

func (context *Context) Join(room string)

Join used to join socketio room

func (*Context) Leave

func (context *Context) Leave(room string)

Leave used to leave socketio room

func (*Context) Param added in v1.0.81

func (context *Context) Param(key string) interface{}

Param used to retrieve params value

func (*Context) ParamBool added in v1.0.81

func (context *Context) ParamBool(key string) bool

ParamBool used to retrieve params value in bool

func (*Context) ParamDict added in v1.0.81

func (context *Context) ParamDict(key string) *helpers.Dictionary

ParamDict used to retrieve params value in dict

func (*Context) ParamFloat64 added in v1.0.81

func (context *Context) ParamFloat64(key string, fallback float64) float64

ParamFloat64 used to retrieve params value in float64

func (*Context) ParamH added in v1.0.82

func (context *Context) ParamH(key string) helpers.H

ParamH used to retrieve params value in H

func (*Context) ParamInt added in v1.0.81

func (context *Context) ParamInt(key string, fallback int) int

ParamInt used to retrieve params value in int

func (*Context) ParamStr added in v1.0.81

func (context *Context) ParamStr(key string) string

ParamStr used to retrieve params value in string

func (*Context) PrepareRender

func (context *Context) PrepareRender(viewName string) *views.Renderer

func (*Context) Property

func (context *Context) Property(key string) interface{}

Property used to retrieve context property value

func (*Context) QueryStr added in v1.0.15

func (context *Context) QueryStr(key string) string

QueryStr used to retrieve params value in string

func (*Context) Rooms

func (context *Context) Rooms() []string

Rooms used to retrieve all connection's rooms

func (*Context) SetErrorResult

func (context *Context) SetErrorResult(err error)

SetErrorResult used to halt controller's chain and acknowledge request with error status and error

func (*Context) SetProperty

func (context *Context) SetProperty(key string, value interface{})

SetProperty used to set property that can used across the context

func (*Context) SetSuccessResult

func (context *Context) SetSuccessResult(content interface{})

SetSuccessResult used to halt controller's chain and acknowledge request with content

func (*Context) SetUnauthorizedResult added in v1.0.76

func (context *Context) SetUnauthorizedResult()

SetUnauthorizedResult used to halt controller's chain and acknowledge request with unthorized status

func (*Context) SingleJoin

func (context *Context) SingleJoin(room string)

SingleJoin used to join socketio room while leaving other joined rooms

type Controllable

type Controllable interface {
	RegisterActions(*ActionsHandler)
}

Controllable is the interface for all controllers implementing RegisterBeforeHooks and RegisterActions

type ControllerHandler

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

ControllerHandler used to handle controller

type Event

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

Event used as medium of communication

func (*Event) Broadcast

func (event *Event) Broadcast(server *socketio.Server)

Broadcast used to broadcast event

type Hook

type Hook func(string, *Context)

Hook is alias for func(string, *Context)

type Manager

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

Manager is singleton manager for controller module

func (*Manager) BroadcastEvent

func (manager *Manager) BroadcastEvent(nsp string, room string, eventName string, view interface{}, parameters helpers.H)

BroadcastEvent used to broadcast event

func (*Manager) RegisterController

func (manager *Manager) RegisterController(nsp string, controllable Controllable)

RegisterController used to register controller

func (*Manager) Serve

func (manager *Manager) Serve(port string, httpHandler func())

Serve used to serve

func (*Manager) Setup

func (manager *Manager) Setup(viewsManager *views.Manager)

Setup used to setup cotroller manager

type Result

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

Result used to wrap request result

func (*Result) Content

func (result *Result) Content() interface{}

Content used to retrieve result's content

func (*Result) ErrorMessage

func (result *Result) ErrorMessage() string

ErrorMessage used to retrieve result's error message

func (*Result) Set

func (result *Result) Set(content interface{}, status string, err error)

Set used to set content, status and error

func (*Result) Status

func (result *Result) Status() string

Status used to retrieve result's status

func (*Result) StatusError

func (result *Result) StatusError() bool

StatusError used to check if request is errored

func (*Result) StatusSuccess

func (result *Result) StatusSuccess() bool

StatusSuccess used to check if request is success

func (*Result) StatusUnauthorized

func (result *Result) StatusUnauthorized() bool

StatusUnauthorized used to check if request is unauthorized

Jump to

Keyboard shortcuts

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