controllers

package
v0.0.0-...-28f6716 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNote

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

Handler for HTTP Post - "/notes" Insert a new Note document for a TaskId

func CreateTask

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

Handler for HTTP Post - "/tasks" Insert a new Task document

func DeleteNote

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

Handler for HTTP Delete - "/notes/{id}" Delete an existing Note document

func DeleteTask

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

Handler for HTTP Delete - "/tasks/{id}" Delete an existing Task document

func GetNoteById

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

Handler for HTTP Get - "/notes/{id}" Returns a single Note document by id

func GetNotes

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

Handler for HTTP Get - "/notes" Returns all Note documents

func GetNotesByTask

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

Handler for HTTP Get - "/notes/tasks/{id} Returns all Notes documents under a TaskId

func GetTaskById

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

Handler for HTTP Get - "/tasks/{id}" Returns a single Task document by id

func GetTasks

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

Handler for HTTP Get - "/tasks" Returns all Task documents

func GetTasksByUser

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

Handler for HTTP Get - "/tasks/users/{id}" Returns all Tasks created by a User

func Login

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

Handler for HTTP Post - "/users/login" Authenticate with username and apssword

func Register

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

Handler for HTTP Post - "/users/register" Add a new User document

func UpdateNote

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

Handler for HTTP Put - "/notes/{id}" Update an existing Note document

func UpdateTask

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

Handler for HTTP Put - "/tasks/{id}" Update an existing Task document

Types

type AuthUserModel

type AuthUserModel struct {
	User  models.User `json:"user"`
	Token string      `json:"token"`
}

Model for authorized user with access token

type AuthUserResource

type AuthUserResource struct {
	Data AuthUserModel `json:"data"`
}

Response for authorized user Post - /user/login

type Context

type Context struct {
	MongoSession *mgo.Session
}

Struct used for maintaining HTTP Request Context

func NewContext

func NewContext() *Context

Create a new Context object for each HTTP request

func (*Context) Close

func (c *Context) Close()

Close mgo.Session

func (*Context) DbCollection

func (c *Context) DbCollection(name string) *mgo.Collection

Returns mgo.collection for the given name

type LoginModel

type LoginModel struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Model for authentication

type LoginResource

type LoginResource struct {
	Data LoginModel `json:"data"`
}

For Post - /user/login

type NoteModel

type NoteModel struct {
	TaskId      string `json:"taskid"`
	Description string `json:"description"`
}

Model for a TaskNote

type NoteResource

type NoteResource struct {
	Data NoteModel `json:"data"`
}

For Post/Put - /notes

type NotesResource

type NotesResource struct {
	Data []models.TaskNote `json:"data"`
}

For Get - /notes For /notes/tasks/id

type TaskResource

type TaskResource struct {
	Data models.Task `json:"data"`
}

For Post/Put - /tasks For Get - /tasks/id

type TasksResource

type TasksResource struct {
	Data []models.Task `json:"data"`
}

For Get - /tasks

type UserResource

type UserResource struct {
	Data models.User `json:"data"`
}

For Post - /user/register

Jump to

Keyboard shortcuts

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