manager

package
v1.0.1-0...-6dc1f34 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const SessionKey = "eve-session"

SessionKey is the key for the cookie in the HTTP header

View Source
const UserContextKey key = "user"

UserContextKey is the key for the user data that is stored in the request context

Variables

This section is empty.

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(s int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GetBotFromRequest

func GetBotFromRequest(r *http.Request) *db.Bot

GetBotFromRequest checks if there is a bot id in the request (HTTP GET e.g. ?bot=2) It also checks if the bot belongs to the authenticated user If no bot id is provided in the request the first bot for the user is returned If an error occures or there is no bot in the request or database nil is returned

func GetUserFromRequest

func GetUserFromRequest(r *http.Request) *db.User

GetUserFromRequest extracts the user stored in the request context If no user is stored, nil is returned

func StartWebServer

func StartWebServer(host string, httpPort int)

StartWebServer creates a handler for incomming http requests on the given host and port The method only returns if the server is shut down or runs into an error

Types

type CreateBotForm

type CreateBotForm struct {
	Name  int       `schema:"nameID"`
	Image int       `schema:"imageID"`
	Sex   db.Gender `schema:"sex"`
}

CreateBotForm is the data needed to create a bot via http request

type MessageRequest

type MessageRequest struct {
	Message string `json:"message"`
	Bot     int    `json:"bot"`
	User    *db.User
}

MessageRequest represents a message request from the user The client sends a message as json string. The json contains a message and the id of the bot the message is sent to.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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