routes

package
v0.0.0-...-cd8c184 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IMAGE_FOLDER_PATH = "./src/res/images/"
)

Variables

This section is empty.

Functions

func UserInterfaceEquals

func UserInterfaceEquals(group1 []db.User, group2 []db.User) bool

Types

type Action

type Action struct {
	Action    string `json:"action"`
	MessageId int64  `json:"messageId"`
}

type Auth

type Auth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Auth is used to validate the username and password given in an http header

type ClientData

type ClientData struct {
	Message       string                 `json:"message"`
	Chatroom      string                 `json:"chatroom"`
	Username      string                 `json:"username"`
	Password      string                 `json:"password"`
	Users         []string               `json:"users"`
	Action        string                 `json:"action"`
	LastMessageId int64                  `json:"lastMessageId"`
	Properties    map[string]interface{} `json:"properties"`
}

type FullData

type FullData struct {
	Messages      []db.Message  `json:"messages"`
	AllUsers      []db.User     `json:"allUsers"`
	Chatrooms     []db.Chatroom `json:"chatrooms"`
	UpdateAvatars string        `json:"updateAvatars"`
}

type ServerActionsController

type ServerActionsController struct {
	Actions     []Action
	ActionCount int64
}

func CreateServerActionsController

func CreateServerActionsController() *ServerActionsController

func (*ServerActionsController) AddDeleteAction

func (sac *ServerActionsController) AddDeleteAction(messageId int64)

func (ServerActionsController) GetNewestAction

func (sac ServerActionsController) GetNewestAction() (Action, error)

type ServerStateController

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

ServerStateController controls the database for each route

func CreateServerStateController

func CreateServerStateController() ServerStateController

CreateServerStateController will create a database connection and return a ServerStateController

func (ServerStateController) AddAvatarToUser

func (serverState ServerStateController) AddAvatarToUser(c *gin.Context)

Adds an avatar image to the image folder and updates the location in the database

func (ServerStateController) ChangePassword

func (serverState ServerStateController) ChangePassword(c *gin.Context)

func (ServerStateController) CreateChatroom

func (serverState ServerStateController) CreateChatroom(c *gin.Context)

func (ServerStateController) CreateUser

func (serverState ServerStateController) CreateUser(c *gin.Context)

func (ServerStateController) GetAvatar

func (serverState ServerStateController) GetAvatar(c *gin.Context)

func (ServerStateController) GetUsernameAndPasswordFromBase64

func (serverState ServerStateController) GetUsernameAndPasswordFromBase64(input string) (Auth, error)

Used to get the username and password from basic auth

func (*ServerStateController) UpdateHandler

func (serverState *ServerStateController) UpdateHandler(wsConn *websocket.Conn, state *State)

func (ServerStateController) ValidateUser

func (serverState ServerStateController) ValidateUser(c *gin.Context) bool

validates the context headers basic auth against the usernames and passwords in the database

func (ServerStateController) VerifyUser

func (serverState ServerStateController) VerifyUser(c *gin.Context)

func (ServerStateController) WebSocket

func (serverState ServerStateController) WebSocket(c *gin.Context)

type State

type State struct {
	LastMessageId int64
	Username      string
	Users         []string
	Chatroom      string
	LoggedIn      bool
	LoggedOut     bool
	MessageLimit  int64
	AllUsers      []db.User
}

type UpdateAvatars

type UpdateAvatars struct {
	UpdateAvatars string `json:"updateAvatars"`
}

Jump to

Keyboard shortcuts

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