handlers

package
v0.0.0-...-24e2e22 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WsChan = make(chan WsPayload)

Functions

func Favicon

func Favicon(w http.ResponseWriter, r *http.Request)

Favicon serves favicon to browser.

func Home

func Home(w http.ResponseWriter, r *http.Request)

Home handles the home route.

func ListenOnWsChan

func ListenOnWsChan()

ListenOnWsChan indefintely listens for new payload on WsChan and processes it according to payload.Action.

func StaticFiles

func StaticFiles(folder string) http.Handler

StaticFiles serves files from provided folder.

func Websocket

func Websocket(w http.ResponseWriter, r *http.Request)

Websocket handles a websocket connection.

Types

type WsPayload

type WsPayload struct {
	Action   string `json:"action"`
	Username string `json:"username"`
	Message  string `json:"message"`
	Conn     wsConn `json:"-"`
}

WsPayload defines the payload received from client.

type WsResponse

type WsResponse struct {
	Action         string   `json:"action"`
	Message        string   `json:"message"`
	MessageType    string   `json:"messageType"`
	ConnectedUsers []string `json:"connectedUsers"`
}

WsResponse defines the response sent back from websocket.

Jump to

Keyboard shortcuts

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