handlers

package
v0.0.0-...-32e7280 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CtxUserID used to access user id
	CtxUserID key = iota
	// CtxAccessToken used to access user token
	CtxAccessToken key = iota
	// CtxUserImage used to access user image
	CtxUserImage key = iota
	// CtxUserFName used to access user first name
	CtxUserFName key = iota
	//CtxUserUName used to access user username
	CtxUserUName key = iota
)

Variables

This section is empty.

Functions

func AuthRequired

func AuthRequired(next http.HandlerFunc) http.HandlerFunc

AuthRequired is middleware that handles auth checking

Types

type Board

type Board struct {
	jsonhal.Hal
	Name        string                 `json:"name"`
	URL         string                 `json:"url"`
	Image       models.PinterestImages `json:"image"`
	Counts      models.PinterestCount  `json:"counts"`
	ID          string                 `json:"id"`
	Description string                 `json:"description"`
	Favorited   bool                   `json:"favorited"`
	LastUpdate  int                    `json:"last_update"`
}

Board describes a board resource

type BoardsResponse

type BoardsResponse struct {
	jsonhal.Hal
	Error string `json:"error,omitempty"`
}

BoardsResponse describes boards for user

type FavoritesResponse

type FavoritesResponse struct {
	jsonhal.Hal
	Favorited bool `json:"favorited"`
}

FavoritesResponse is our response to a favorites request

type Handlers

type Handlers struct {
	DB *sql.DB
}

Handlers is the wrapper for handlers

func (*Handlers) AuthHandler

func (h *Handlers) AuthHandler(w http.ResponseWriter, r *http.Request)

AuthHandler redirects a user to the pinterest oauth

func (*Handlers) BoardsHandler

func (h *Handlers) BoardsHandler(w http.ResponseWriter, r *http.Request)

BoardsHandler Gets a list of user's boards

func (*Handlers) CatchHandler

func (h *Handlers) CatchHandler(w http.ResponseWriter, r *http.Request)

CatchHandler handles the oauth catch

func (*Handlers) FavoritesHandler

func (h *Handlers) FavoritesHandler(w http.ResponseWriter, r *http.Request)

FavoritesHandler Gets a list of user's boards

func (*Handlers) HomeHandler

func (h *Handlers) HomeHandler(w http.ResponseWriter, r *http.Request)

HomeHandler handles the root api listing

func (*Handlers) LogoutHandler

func (h *Handlers) LogoutHandler(w http.ResponseWriter, r *http.Request)

LogoutHandler removes a user's JWT and redirects them back to the app

func (*Handlers) RecipesHandler

func (h *Handlers) RecipesHandler(w http.ResponseWriter, r *http.Request)

RecipesHandler Gets a list of user's boards

type HomeResponse

type HomeResponse struct {
	jsonhal.Hal
}

HomeResponse is a response model for home

type PindishClaims

type PindishClaims struct {
	ID    string `json:"id"`
	Token string `json:"token"`
	FName string `json:"fname"`
	UName string `json:"uname"`
	Image string `json:"image"`
	jwt.StandardClaims
}

PindishClaims are the custom claims for pindish

type Recipe

type Recipe struct {
	jsonhal.Hal
	ID       int                    `json:"id"`
	Image    models.PinterestImages `json:"image"`
	Link     string                 `json:"link"`
	Servings struct {
		Serves  string `json:"serves"`
		Summary string `json:"summary"`
	} `json:"servings"`
	Name        string                      `json:"name"`
	Ingredients []models.IngredientCategory `json:"ingredients"`
}

Recipe describes a recipe

type RecipesResponse

type RecipesResponse struct {
	jsonhal.Hal
	Error string `json:"error,omitempty"`
}

RecipesResponse describes boards for user

type User

type User struct {
	Name     string `json:"name"`
	Image    string `json:"image"`
	Username string `json:"username"`
}

User describes a user

Jump to

Keyboard shortcuts

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