controllers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2016 License: MIT Imports: 9 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)

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

func CreateTask

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

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

func DeleteNote

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

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

func DeleteTask

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

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

func GetNoteByID

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

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

func GetNotes

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

GetNotes returns all Note documents Handler for HTTP Get - "/notes"

func GetNotesByTask

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

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

func GetTaskByID

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

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

func GetTasks

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

GetTasks returns all Task document Handler for HTTP Get - "/tasks"

func GetTasksByUser

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

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

func Login

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

Login authenticates the HTTP request with username and apssword Handler for HTTP Post - "/users/login"

func Register

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

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

func UpdateNote

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

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

func UpdateTask

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

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

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
	User         string
}

Context used for maintaining HTTP Request Context

func NewContext

func NewContext() *Context

NewContext creates 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

DbCollection 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