controllers

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: MIT Imports: 9 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 added in v0.0.21

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 added in v0.0.21

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

RegisterAction used to register action

func (*ActionsHandler) RegisterConnectedAction added in v0.0.37

func (handler *ActionsHandler) RegisterConnectedAction(action Action)

RegisterConnectedAction used to register connected action

func (*ActionsHandler) RegisterDisconnectedAction added in v0.0.37

func (handler *ActionsHandler) RegisterDisconnectedAction(action Action)

RegisterDisconnectedAction used to register disconnected action

func (*ActionsHandler) RegisterErrorAction added in v0.0.37

func (handler *ActionsHandler) RegisterErrorAction(action Action)

RegisterErrorAction used to register error action

type Context added in v0.0.21

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

Context used to represent context with properties and params

func (*Context) Join added in v0.0.21

func (context *Context) Join(room string)

Join used to join socketio room

func (*Context) Leave added in v0.0.21

func (context *Context) Leave(room string)

Leave used to leave socketio room

func (*Context) Params added in v0.0.21

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

Params used to retrieve params value

func (*Context) ParamsBool added in v0.0.72

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

ParamsBool used to retrieve params value in bool

func (*Context) ParamsFloat64 added in v0.0.62

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

ParamsFloat64 used to retrieve params value in float64

func (*Context) ParamsInt added in v0.0.21

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

ParamsInt used to retrieve params value in int

func (*Context) ParamsStr added in v0.0.21

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

ParamsStr used to retrieve params value in string

func (*Context) PrepareRender added in v0.1.3

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

func (*Context) Property added in v0.0.21

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

Property used to retrieve context property value

func (*Context) Rooms added in v0.0.21

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

Rooms used to retrieve all connection's rooms

func (*Context) SetErrorResult added in v0.0.60

func (context *Context) SetErrorResult(status string, err error)

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

func (*Context) SetProperty added in v0.0.21

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

SetProperty used to set property that can used across the context

func (*Context) SetSuccessResult added in v0.0.60

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

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

func (*Context) SingleJoin added in v0.0.21

func (context *Context) SingleJoin(room string)

SingleJoin used to join socketio room while leaving other joined rooms

type Controllable added in v0.0.21

type Controllable interface {
	RegisterHooksAndActions(*HooksHandler, *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 added in v0.0.21

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

Event used as medium of communication

func (*Event) Broadcast added in v0.0.21

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

Broadcast used to broadcast event

type Hook added in v0.0.21

type Hook func(string, *Context)

Hook is alias for Hook

type HooksHandler added in v0.0.21

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

HooksHandler used to mange callbacks for controllers

func (*HooksHandler) RegisterBeforeActionHook added in v0.0.39

func (handler *HooksHandler) RegisterBeforeActionHook(beforeActionHook Hook)

RegisterBeforeActionHook used to add before hook

type Manager added in v0.0.21

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

Manager is singleton manager for controller module

func (*Manager) BroadcastEvent added in v0.0.21

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

BroadcastEvent used to broadcast event

func (*Manager) RegisterController added in v0.0.21

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

RegisterController used to register controller

func (*Manager) Serve added in v0.0.21

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

Serve used to serve

func (*Manager) Setup added in v0.0.21

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

Setup used to setup cotroller manager

type Result added in v0.0.57

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

Result used to wrap request result

func (*Result) Content added in v0.0.57

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

Content used to retrieve result's content

func (*Result) ErrorMessage added in v0.0.57

func (result *Result) ErrorMessage() string

ErrorMessage used to retrieve result's error message

func (*Result) Set added in v0.0.57

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

Set used to set content, status and error

func (*Result) Status added in v0.0.57

func (result *Result) Status() string

Status used to retrieve result's status

func (*Result) StatusError added in v0.0.57

func (result *Result) StatusError() bool

StatusError used to check if request is errored

func (*Result) StatusSuccess added in v0.0.57

func (result *Result) StatusSuccess() bool

StatusSuccess used to check if request is success

func (*Result) StatusUnauthorized added in v0.0.57

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