routes

package
v0.0.0-...-bd48299 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShiftPath

func ShiftPath(p string) (head, tail string)

ShiftPath splits off the first component of p, which will be cleaned of relative components before processing. head will never contain a slash and tail will always be a rooted path without trailing slash.

Types

type APIRouter

type APIRouter struct {
	Services        *Services
	AuthRouter      *AuthRouter
	MatchRouter     *MatchRouter
	UserRouter      *UserRouter
	CharacterRouter *CharacterRouter
	TagRouter       *TagRouter
}

APIRouter is responsible for serving "/api" or delegating to the appropriate sub api-router

func NewAPIRouter

func NewAPIRouter(routerServices *Services) *APIRouter

NewAPIRouter makes a new api router and sets up its children routers with access to our router services

func (*APIRouter) ServeHTTP

func (r *APIRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type AppRouter

type AppRouter struct {
	Services     *Services
	APIRouter    *APIRouter
	StaticRouter *StaticRouter
}

AppRouter is the router responsible for serving "/" or delegating to the appropriate sub router

func NewRouter

func NewRouter() *AppRouter

NewRouter makes a new app router and sets up its children routers with access to the router services

func (*AppRouter) ServeHTTP

func (r *AppRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type AuthRouter

type AuthRouter struct {
	Services *Services
}

AuthRouter handles all of the authentication related routes

func NewAuthRouter

func NewAuthRouter(routerServices *Services) *AuthRouter

NewAuthRouter makes a new api/auth router and hooks up its services

func (*AuthRouter) ServeHTTP

func (r *AuthRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type CharacterCreateResponseData

type CharacterCreateResponseData struct {
	Character *db.Character `json:"character"`
}

CharacterCreateResponseData is the data we send back after a successfully creating a new character

type CharacterGetAllResponseData

type CharacterGetAllResponseData struct {
	Characters []*db.Character `json:"characters"`
}

CharacterGetAllResponseData is the data we send back after a successfully getting all character data

type CharacterRouter

type CharacterRouter struct {
	Services *Services
}

CharacterRouter is responsible for serving "/api/character" Basically, connecting to our Postgres DB for all of the CRUD operations for our "Character" models

func NewCharacterRouter

func NewCharacterRouter(routerServices *Services) *CharacterRouter

NewCharacterRouter makes a new api/character router and hooks up its services

func (*CharacterRouter) ServeHTTP

func (r *CharacterRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type CharacterUpdateResponseData

type CharacterUpdateResponseData struct {
	Character *db.Character `json:"character"`
}

CharacterUpdateResponseData is the data we send back after a successfully udpating a new character

type ForgotPasswordRequestData

type ForgotPasswordRequestData struct {
	UserEmail string `json:"userEmail"`
}

ForgotPasswordRequestData describes the data we're expecting when a user requests to send an email to reset their password

type LoginRequestData

type LoginRequestData struct {
	EmailAddress string `json:"emailAddress"`
	Password     string `json:"password"`
}

LoginRequestData describes the data we're expecting when a user attempts to log in

type LoginResponseData

type LoginResponseData struct {
	User              *db.UserProfileView     `json:"user"`
	UserCharacters    []*db.UserCharacterView `json:"userCharacters"`
	AccessExpiration  time.Time               `json:"accessExpiration"`
	RefreshExpiration time.Time               `json:"refreshExpiration"`
}

LoginResponseData is the data we send back after a successful log in

type LogoutRequestData

type LogoutRequestData struct {
	UserID int64 `json:"userId"`
}

LogoutRequestData describes the data we're expecting when a user attempts to log out

type LogoutResponseData

type LogoutResponseData struct {
	UserID int64 `json:"userId"`
}

LogoutResponseData is the data we send back after a successful log out

type MatchCreateResponseData

type MatchCreateResponseData struct {
	Match *db.MatchView `json:"match"`
}

MatchCreateResponseData is the data we send back after a successfully creating a new match

type MatchGetAllResponseData

type MatchGetAllResponseData struct {
	Matches []*db.MatchView `json:"matches"`
}

MatchGetAllResponseData is the data we send back after a successfully get info for all matches in our db

type MatchRouter

type MatchRouter struct {
	Services *Services
}

MatchRouter is responsible for serving "/api/matches" Basically, connecting to our Postgres DB for all of the CRUD operations for our "Match" models

func NewMatchRouter

func NewMatchRouter(routerServices *Services) *MatchRouter

NewMatchRouter makes a new api/match router and hooks up its services

func (*MatchRouter) ServeHTTP

func (r *MatchRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type MatchUpdateResponseData

type MatchUpdateResponseData struct {
	Match *db.MatchView `json:"match"`
}

MatchUpdateResponseData is the data we send back after successfully updating a match

type RefreshRequestData

type RefreshRequestData struct {
	UserID int64 `json:"userId"`
}

RefreshRequestData describes the data we're expecting when a user attempts refresh their access token

type RefreshResponseData

type RefreshResponseData struct {
	AccessExpiration time.Time `json:"accessExpiration"`
}

RefreshResponseData is the data we send back after a successful refresh

type RegisterRequestData

type RegisterRequestData struct {
	UserName     string `json:"userName"`
	EmailAddress string `json:"emailAddress"`
	Password     string `json:"password"`
}

RegisterRequestData describes the data we're expecting when a user attempts register

type RegisterResponseData

type RegisterResponseData struct {
	UserID int64 `json:"userId"`
}

RegisterResponseData is the data we send back after a successful register

type ResetPasswordRequestData

type ResetPasswordRequestData struct {
	Token       string `json:"token"`
	NewPassword string `json:"newPassword"`
}

ResetPasswordRequestData describes the data we're expecting when a user requests to reset their password

type Response

type Response struct {
	Success bool        `json:"success"`
	Error   error       `json:"error"`
	Data    interface{} `json:"data"`
}

Response is the data

type Services

type Services struct {
	Database db.DatabaseManager
	Auth     auth.Authenticator
	Email    email.Emailer
}

Services describes what services are available to all routes in our application

func NewRouterServices

func NewRouterServices() *Services

NewRouterServices initializes all of the services available to our routers

type StaticRouter

type StaticRouter struct{}

StaticRouter is responsible for serving "/static"

func NewStaticRouter

func NewStaticRouter() *StaticRouter

NewStaticRouter makes a new api/user router for serving our static assets

func (*StaticRouter) ServeHTTP

func (r *StaticRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type TagCreateResponseData

type TagCreateResponseData struct {
	Tag *db.Tag `json:"tag"`
}

TagCreateResponseData describes the data we send back after successfully creating a new tag

type TagGetAllResponseData

type TagGetAllResponseData struct {
	Tags []*db.Tag `json:"tags"`
}

TagGetAllResponseData is the data we send back after a successfully getiing all tags in our db

type TagRouter

type TagRouter struct {
	Services *Services
}

TagRouter is responsible for serving /api/tag

func NewTagRouter

func NewTagRouter(routerServices *Services) *TagRouter

NewTagRouter makes a new api/tag router and hooks up its services

func (*TagRouter) ServeHTTP

func (r *TagRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type TagUpdateResponseData

type TagUpdateResponseData struct {
	Tag *db.Tag `json:"tag"`
}

TagUpdateResponseData describes the data we send back after successfully updating an existing tag

type UserCharacterCreateResponseData

type UserCharacterCreateResponseData struct {
	UserCharacters []*db.UserCharacterView `json:"userCharacters"`
	User           *db.UserProfileView     `json:"user"`
}

UserCharacterCreateResponseData is the data we send back after a successfully creating a new "saved character" for a given user

type UserCharacterDeleteResponseData

type UserCharacterDeleteResponseData struct {
	UserCharacters []*db.UserCharacterView `json:"userCharacters"`
	User           *db.UserProfileView     `json:"user"`
}

UserCharacterDeleteResponseData is the data we send back after a successfully deleting a "saved character" for a given user

type UserCharacterRouter

type UserCharacterRouter struct {
	Services *Services
}

UserCharacterRouter handles all of /api/user/character

func NewUserCharacterRouter

func NewUserCharacterRouter(routerServices *Services) *UserCharacterRouter

NewUserCharacterRouter makes a new api/user/character router and hooks up its services

func (*UserCharacterRouter) ServeHTTP

func (r *UserCharacterRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type UserCharacterUpdateResponseData

type UserCharacterUpdateResponseData struct {
	UserCharacters []*db.UserCharacterView `json:"userCharacters"`
	User           *db.UserProfileView     `json:"user"`
}

UserCharacterUpdateResponseData is the data we send back after a successfully creating a new "saved character" for a given user

type UserGetAllResponseData

type UserGetAllResponseData struct {
	Users []*db.User `json:"users"`
}

type UserGetResponseData

type UserGetResponseData struct {
	User           *db.UserProfileView     `json:"user"`
	UserCharacters []*db.UserCharacterView `json:"userCharacters"`
}

UserGetResponseData is the data we send back after a successfully getting all user's info

type UserRouter

type UserRouter struct {
	Services            *Services
	UserCharacterRouter *UserCharacterRouter
}

UserRouter is responsible for serving "/api/user" Basically, connecting to our Postgres DB for all of the CRUD operations for our "User" models

func NewUserRouter

func NewUserRouter(routerServices *Services) *UserRouter

NewUserRouter makes a new api/user router and hooks up its services

func (*UserRouter) ServeHTTP

func (r *UserRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)

type UserUpdateDefaultUserCharacterResponseData

type UserUpdateDefaultUserCharacterResponseData struct {
	User           *db.UserProfileView     `json:"user"`
	UserCharacters []*db.UserCharacterView `json:"userCharacters"`
}

UserUpdateDefaultUserCharacterResponseData is the data we send back after successfully updating a user's default user character

type UserUpdateResponseData

type UserUpdateResponseData struct {
	User           *db.UserProfileView     `json:"user"`
	UserCharacters []*db.UserCharacterView `json:"userCharacters"`
}

UserUpdateResponseData is the data we send back after a successfully creating a new user

Jump to

Keyboard shortcuts

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