handlers

package
v0.0.0-...-426ce78 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx *fasthttp.RequestCtx)

Create is a dynamic handler for POST requests

func GetData

func GetData(dataset string) interface{}

GetData gets the data in the file represented by the supplied dataset

func Login

func Login(ctx *fasthttp.RequestCtx)

Login allows returning users to get their auth token to login to the applications REST functions

func Lookup

func Lookup(ctx *fasthttp.RequestCtx)

Lookup is a dynamic handler for lookup datasets

func PostData

func PostData(dataset string, byteData []byte) interface{}

PostData determines what dataset is being posted and dispatches the byte data to the correct handler

func Register

func Register(ctx *fasthttp.RequestCtx)

Register is the registration handler to create an account to allow the user to traverse the API through the auth middleware

func WriteJSONData

func WriteJSONData(dataset string, byteData []byte)

WriteJSONData writes the byte data to the specified dataset

Types

type LookupRecord

type LookupRecord struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

LookupRecord is a struct that represents the common shape of the JSON data used for simple lookup datasets.

func ParseLookup

func ParseLookup(byteData []byte) []LookupRecord

ParseLookup takes a []byte from a JSON file and parses the data into an array of LookupRecords

type MonsterRecord

type MonsterRecord struct {
	ID               int                           `json:"id"`
	Name             string                        `json:"name"`
	HitPoints        string                        `json:"hitpoints"`
	ArmorClass       string                        `json:"armorclass"`
	STR              int                           `json:"STR"`
	DEX              int                           `json:"DEX"`
	CON              int                           `json:"CON"`
	INT              int                           `json:"INT"`
	WIS              int                           `json:"WIS"`
	CHA              int                           `json:"CHA"`
	Challenge        int                           `json:"challenge"`
	Traits           string                        `json:"traits"`
	Actions          string                        `json:"actions"`
	LegendaryActions string                        `json:"legendaryactions"`
	Reactions        string                        `json:"reactions"`
	Related          map[string][]RelationalRecord `json:"related"`
}

MonsterRecord is a struct representing the data structure of Monsters

func CreateMonster

func CreateMonster(dataset string, byteData []byte) MonsterRecord

CreateMonster enters a new monster data entry into the database.

func ParseMonster

func ParseMonster(byteData []byte) []MonsterRecord

ParseMonster takes []byte from a JSON file and parses out monsters and all related data into a monster list.

type RawMonsterRecord

type RawMonsterRecord struct {
	ID               int              `json:"id"`
	Name             string           `json:"name"`
	HitPoints        string           `json:"hitpoints"`
	ArmorClass       string           `json:"armorclass"`
	STR              int              `json:"STR"`
	DEX              int              `json:"DEX"`
	CON              int              `json:"CON"`
	INT              int              `json:"INT"`
	WIS              int              `json:"WIS"`
	CHA              int              `json:"CHA"`
	Challenge        int              `json:"challenge"`
	Traits           string           `json:"traits"`
	Actions          string           `json:"actions"`
	LegendaryActions string           `json:"legendaryactions"`
	Reactions        string           `json:"reactions"`
	Related          map[string][]int `json:"related"`
}

RawMonsterRecord is a struct representing the data structure of Monsters

type RawRelationalRecord

type RawRelationalRecord struct {
	ID      int    `json:"id"`
	Value   string `json:"value"`
	Related int    `json:"related"`
}

RawRelationalRecord is a struct that represents the common shape of the JSON data for relational datasets.

type RelationalRecord

type RelationalRecord struct {
	ID      int          `json:"id"`
	Value   string       `json:"value"`
	Related LookupRecord `json:"related"`
}

RelationalRecord is a struct that represents the common shape of the JSON data for relational datasets with a parsed lookup related reference

func CreateRelational

func CreateRelational(dataset string, lookupDataset string, byteData []byte) RelationalRecord

CreateRelational creates a relational data entry to be written to a file

func ParseRelational

func ParseRelational(byteData []byte, lookupDataset string) []RelationalRecord

ParseRelational takes []byte from a JSON file and its related lookupDataset to parse into a complete array of RelationalRecords

Jump to

Keyboard shortcuts

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