Documentation ¶
Overview ¶
Package recipe provides functionality for managing recipes.
Index ¶
- func DeleteRecipe(w http.ResponseWriter, r *http.Request)
- func GetAllRecipes(w http.ResponseWriter, r *http.Request)
- func GetRecipe(w http.ResponseWriter, r *http.Request)
- func MakeMuxer(prefix string) http.Handler
- func NewRecipeHelper(c appengine.Context, w http.ResponseWriter, r *http.Request, recipe *Recipe) bool
- func PostRecipe(w http.ResponseWriter, r *http.Request)
- func PutRecipe(w http.ResponseWriter, r *http.Request)
- func PutRecipeHelper(c appengine.Context, w http.ResponseWriter, r *http.Request, l *Recipe) bool
- type Recipe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteRecipe ¶
func DeleteRecipe(w http.ResponseWriter, r *http.Request)
DeleteRecipe deletes the recipe for the given tag. The currently logged in user must own the recipe. Otherwise, an unauthorized error is returned.
func GetAllRecipes ¶
func GetAllRecipes(w http.ResponseWriter, r *http.Request)
GetAllRecipes fetches all of the recipes.
func GetRecipe ¶
func GetRecipe(w http.ResponseWriter, r *http.Request)
GetRecipe fetches the recipe for the given tag.
func MakeMuxer ¶
MakeMuxer creates a http.Handler to manage all recipe operations. If a prefix is given, that prefix will be the first part of the url. This muxer will provide the following handlers and return a RESTful 404 on all others.
GET prefix + / Get all recipes. POST prefix + / Create a new recipe. GET prefix + /{key}/ Get the recipe for the given key. PUT prefix + /{key}/ Update the recipe with the given key. DELETE prefix + /{key}/ Delete the recipe with the given key.
See the functions related to these urls for more details on what each one does and the requirements behind it.
func NewRecipeHelper ¶
func NewRecipeHelper(c appengine.Context, w http.ResponseWriter, r *http.Request, recipe *Recipe) bool
NewRecipeHelper is a helper function that creates a new recipe in the datastore for the given recipe. If the URL field is not empty and the direction and ingredients are, an attempt is made to parse the recipe from the URL. If a failure occured, false is returned and a response was returned to the request. This case should be terminal.
func PostRecipe ¶
func PostRecipe(w http.ResponseWriter, r *http.Request)
PostRecipe creates a new recipe from the POSTed data. If a URL was given and the ingredients and diretions are blank, the information will be pulled from a URL if possible.
func PutRecipe ¶
func PutRecipe(w http.ResponseWriter, r *http.Request)
PutRecipe saves the recipe for the given tag.
func PutRecipeHelper ¶
PutRecipeHelepr saves the recipe to the datastore. If the recipe doesn't have a key, a key will be made for it.
Types ¶
type Recipe ¶
type Recipe struct { // A URL safe version of the datastores key for this recipe item. Key string `datastore:",noindex"` // The title of the recipe. Name string // The URL where the recipe was originally pulled from. URL string `datastore:",noindex"` // This is the time the recipe was last modified. LastModified time.Time // The list of ingredients. Ingredients []string `datastore:",noindex"` // The list of directions. Directions []string `datastore:",noindex"` }
Recipe is a list of ingredients and directions.
func GetRecipeHelper ¶
func GetRecipeHelper(c appengine.Context, w http.ResponseWriter, r *http.Request, key string) (*Recipe, bool)
GetRecipeHelper is a helper function that retrieves a recipe and it's items from the datastore. If a failure occured, false is returned and a response was returned to the request. This case should be terminal.