backend

package
v0.0.0-...-6d869ac Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package backend exposes a REST API to manage posts stored in the Google Cloud Datastore using the Cloud Endpoints feature of App Engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRequest

type AddRequest struct {
	Text     string
	Username string
	Avatar   string
}

AddRequest contains all the fields needed to create a new Post.

type Post

type Post struct {
	UID      *datastore.Key `json:"uid" datastore:"-"`
	Text     string         `json:"text"`
	Username string         `json:"username"`
	Avatar   string         `json:"avatar"`
	Favorite bool           `json:"favorite"`
}

A Post contains all the information related to a post.

type Posts

type Posts struct {
	Posts []Post `json:"posts"`
}

Posts contains a slice of posts. This type is needed because go-endpoints only supports pointers to structs as input and output types.

type PostsAPI

type PostsAPI struct{}

PostsAPI defines all the endpoints of the posts API.

func (PostsAPI) Add

func (PostsAPI) Add(c context.Context, r *AddRequest) (*Post, error)

Add creates a new post given the fields in AddRequest, stores it in the datastore, and returns it.

func (PostsAPI) List

func (PostsAPI) List(c context.Context) (*Posts, error)

List returns a list of all the existing posts.

func (PostsAPI) SetFavorite

func (PostsAPI) SetFavorite(c context.Context, r *SetFavoriteRequest) error

SetFavorite changes the favorite status of a post given its UID.

type SetFavoriteRequest

type SetFavoriteRequest struct {
	UID      *datastore.Key
	Favorite bool
}

SetFavoriteRequest contains the information needed to change the favorite status of a post.

Jump to

Keyboard shortcuts

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