web

package
v0.0.0-...-0f828a4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicUserInformationResult

type BasicUserInformationResult struct {
	ID          uint   `json:"id,omitempty"`
	Username    string `json:"username"`
	models.Role `json:"role,omitempty"`
}

type DeckCreateRequest

type DeckCreateRequest struct {
	Name       string   `json:"name" binding:"required"`
	Official   bool     `json:"official"`
	BlackCards []string `json:"blackCards" binding:"required"`
	WhiteCards []string `json:"whiteCards" binding:"required"`
}

func (*DeckCreateRequest) AmountBlackCards

func (dcr *DeckCreateRequest) AmountBlackCards() int

Returns the amount of black cards in this creation request.

func (*DeckCreateRequest) AmountWhiteCards

func (dcr *DeckCreateRequest) AmountWhiteCards() int

Returns the amount of white cards in this creation request.

type DeckInfoResponse

type DeckInfoResponse struct {
	ID         uint                        `json:"id"`
	Name       string                      `json:"name"`
	Official   bool                        `json:"official"`
	OwnerID    uint                        `json:"ownerId"`
	BlackCards []DeckInfoResponseBlackCard `json:"blackCards"`
	WhiteCards []DeckInfoResponseWhiteCard `json:"whiteCards"`
}

type DeckInfoResponseBlackCard

type DeckInfoResponseBlackCard struct {
	ID     uint   `json:"id"`
	Text   string `json:"text"`
	Blanks uint   `json:"blanks"`
}

type DeckInfoResponseWhiteCard

type DeckInfoResponseWhiteCard struct {
	ID   uint   `json:"id"`
	Text string `json:"text"`
}

type RandomCardRequests

type RandomCardRequests struct {
	DeckIDs []uint              `json:"deckIds" binding:"required"`
	Type    validators.CardType `json:"type" binding:"required,cardtype"`
	Amount  uint                `json:"amount" binding:"required"`
}

type RandomCardResponse

type RandomCardResponse struct {
	Cards []interface{} `json:"cards"`
}

type RouteController

type RouteController struct {
	RouteEnvironment
}

Contains all routes.

func NewRouteController

func NewRouteController(environment RouteEnvironment) *RouteController

Returns a new RouteController instance.

func (*RouteController) AuthInfo

func (rc *RouteController) AuthInfo(c *gin.Context)

Shows some basic information about the authenticated users.

func (*RouteController) DeckCreate

func (rc *RouteController) DeckCreate(c *gin.Context)

Responsible for deck creation.

func (*RouteController) DeckInfo

func (rc *RouteController) DeckInfo(c *gin.Context)

Shows information about a deck

func (*RouteController) Login

func (rc *RouteController) Login(c *gin.Context)

Responsible for user login.

func (*RouteController) RandomCards

func (rc *RouteController) RandomCards(c *gin.Context)

Returns random cards. Currently it can happen that it returns a card slice that has the length zero when invalid data (e.g. non-existent deck ids or no deck ids at all) is supplied. At the moment, this can be ignored since this is not a public route.

func (*RouteController) Reachable

func (rc *RouteController) Reachable(c *gin.Context)

Just a route that returns an empty HTTP response with a status code of 200 (OK).

func (*RouteController) Register

func (rc *RouteController) Register(c *gin.Context)

Responsible for user creation.

type RouteEnvironment

type RouteEnvironment struct {
	UserRepo repositories.UserRepository
	DeckRepo repositories.DeckRepository
}

Contains everything that is needed for the api so it can operate smoothly. This includes repositories or additional external hooks, for example.

type Router

type Router struct {
	RouteEnvironment
}

func NewRouter

func NewRouter(environment RouteEnvironment) *Router

Creates a new Router instance.

func (*Router) GetEngine

func (router *Router) GetEngine() *gin.Engine

Returns a gin.Engine with the necessary setup for the server.

type UserLoginResponse

type UserLoginResponse struct {
	UserID       uint   `json:"userId"`
	Username     string `json:"username"`
	models.Role  `json:"role,omitempty"`
	Jwt          string    `json:"jwt"`
	SessionToken string    `json:"sessionToken"`
	ValidUntil   time.Time `json:"validUntil"`
}

type UserRequest

type UserRequest struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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