link

package
v0.0.0-...-e27359b Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2016 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package link provides functionality for managing links.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteLink(w http.ResponseWriter, r *http.Request)

DeleteLink deletes the link for the given tag. The currently logged in user must own the link. Otherwise, an unauthorized error is returned.

func GetAllLinks(w http.ResponseWriter, r *http.Request)

GetAllLinks fetches all of the links.

func GetLink(w http.ResponseWriter, r *http.Request)

GetLink fetches the link for the given tag.

func MakeMuxer

func MakeMuxer(prefix string) http.Handler

MakeMuxer creates a http.Handler to manage all link 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 links.
POST    prefix + /        Create a new link.

GET     prefix + /{key}/  Get the link for the given key.
PUT     prefix + /{key}/  Update the link with the given key.
DELETE  prefix + /{key}/  Delete the link 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 NewLinkHelper

func NewLinkHelper(c appengine.Context, w http.ResponseWriter,
	r *http.Request, l *Link) bool

NewLinkHelper is a helper function that creates a new link in the datastore for the given link. The given link is updated with new keys. If a failure occured, false is returned and a response was returned to the request. This case should be terminal.

func PostLink(w http.ResponseWriter, r *http.Request)

PostLink creates a new link from the POSTed data.

func PutLink(w http.ResponseWriter, r *http.Request)

PutLink saves the link for the given tag.

func PutLinkHelper

func PutLinkHelper(c appengine.Context, w http.ResponseWriter,
	r *http.Request, l *Link) bool

PutLinkHelepr saves the link. If the link or any of it's items don't have a key, a key will be made for it.

Types

type Link struct {
	// The name of the link.
	Name string

	// A URL safe version of the datastores key for this link. It
	// is not stored in the datastore.
	Key string `datastore:",noindex"`

	// The Url is the location of the link.
	Url string `datastore:",noindex"`

	// The Icon is the bootstrap icon to display. See:
	// http://twitter.github.com/bootstrap/base-css.html#icons
	Icon string `datastore:",noindex"`

	// The Description is the description of the link
	Description string `datastore:",noindex"`

	// Tags are the searchable elements of a link.
	Tags []string
}

Link is the structure used to save, get, and delete links from the datastore.

func GetLinkHelper

func GetLinkHelper(c appengine.Context, w http.ResponseWriter,
	r *http.Request, key string) (*Link, bool)

GetLinkHelper is a helper function that retrieves a link from the datastore. If a failure occured, false is returned and a response was returned to the request. This case should be terminal.

Jump to

Keyboard shortcuts

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