internal

package
v0.0.0-...-3ee45e0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnabledBool

func GetEnabledBool(enabledStr string) *bool

func UnmarshalBSONToStruct

func UnmarshalBSONToStruct(data []byte, structType interface{}, subField interface{}) error

unmarshalBSONToStruct is a custom unmarshal function, that will unmarshal BSON to structs. This function is to be used when a subfield can take multiple types i.e. storing question data differently for different games. It will unmarshal that field (polymorphic one) i.e. `Questions`, into BSON raw data. This can then be cast into the correct struct for the polymorphic field.

The first unmarshal gets the Raw BSON data. The Raw BSON data allows us to unmarshal sub-objects like `Questions` field to a specific struct.

The second unmarshal converts the raw BSON data into a struct i.e. `QuestionPool`, note in this example `Questions`

field is type `interface{}`.

Next, we unmarshal the subField into raw BSON data, in the example above this would be the `Questions` field. This way we only have raw BSON data related to that field and can be cast appropriate.

func UnmarshalJSONToStruct

func UnmarshalJSONToStruct(data []byte, structType interface{}, subField interface{}) error

Refer to the BSON function above, this function works almost exactly the same as the one above.

Types

type GameParams

type GameParams struct {
	GameName string `description:"The name of the game." example:"quibly" path:"game_name" validate:"required"`
}

type RoundParams

type RoundParams struct {
	Round string `description:"Name of the round for a game." validate:"required" example:"free_form" query:"round"`
}

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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