controllers

package
v0.0.0-...-ad65d08 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_LIMIT int = 10
View Source
const DEFAULT_SKIP int = 0

Variables

View Source
var (
	Database *mongodm.Connection
)

Functions

This section is empty.

Types

type MessageController

type MessageController struct {
	// contains filtered or unexported fields
}

func (*MessageController) Create

func (self *MessageController) Create()

*

  • @api {post} /message Create Message *
  • @apiName Create
  • @apiGroup Message *
  • @apiVersion 0.0.1 *
  • @apiDescription Create a new message with the specified, required fields. *
  • @apiUse ErrorInternal * *
  • @apiParam {Object} message The message object with all required fields
  • @apiParam {String(ObjectID)} message.sender The objectID of the sender (user)
  • @apiParam {Array(String(ObjectID))} message.receiver List containing objectIDs for all receivers (users)
  • @apiParam {String} message.text Message content * *
  • @apiSuccess {Object} message The message object which was created (unpopulated). *
  • @apiSuccessExample {json} Success-Response
  • HTTP/1.1 201 Created
  • { "message": { "id": "571101e7e5feae48d8000001", "createdAt": "2016-04-15T16:59:51.97721049+02:00", "updatedAt": "2016-04-15T16:59:51.97721049+02:00", "sender": "564ca693e5feae2532000002", "receiver": [ "564ca693e5feae2532000002" ], "text": "Some message.." } }
*
* @apiError NotWrapped The message attributes were not wrapped in a message object (key)
*
* @apiErrorExample {json} Object not wrapped in typename
{
  "error": {
    "code": 400,
    "message": "Bad Request",
    "userInfo": [
      {
        "message": "object not wrapped in typename"
      }
    ]
  }
}
*
* @apiError MissingInvalidFields Some of the required fields are missing or invalid
*
* @apiErrorExample {json} Missing or invalid fields
*HTTP/1.1 400 Bad Request
{
  "error": {
    "code": 400,
    "message": "Bad Request",
    "userInfo": [
      {
        "message": "Field 'sender' is required."
      },
      {
        "message": "Field 'receiver' is required."
      },
      {
        "message": "Field 'text' is required."
      }
    ]
  }
}

func (*MessageController) GetAll

func (self *MessageController) GetAll()

*

  • @api {get} /message Get All *
  • @apiName Index
  • @apiGroup Message *
  • @apiVersion 0.0.1 *
  • @apiDescription Fetches all messages *
  • @apiUse ErrorInternal *
  • @apiUse Pagination *
  • @apiSuccess {Array(Message)} messages The array of all messages
  • @apiSuccess {String} message.id User ID
  • @apiSuccess {String} message.createdAt Timestamp of first creation
  • @apiSuccess {String} message.updatedAt Timestamp of last update
  • @apiSuccess {User} message.sender User object of sender
  • @apiSuccess {Array(User)} message.receiver List of user objects (receiver)
  • @apiSuccess {String} message.text Message content *
  • @apiSuccessExample {json} Success-Response
  • HTTP/1.1 201 Created
  • { "messages": [ { "id": "564ca693e5feae2532000002", "createdAt": "2015-11-18T17:25:55.052+01:00", "updatedAt": "2015-11-18T17:25:55.052+01:00", "sender": { "id": "564c87e1e5feae0e3a000001", "createdAt": "2015-11-18T15:14:57.081+01:00", "updatedAt": "2015-11-18T15:14:57.081+01:00", "firstname": "Bob", "lastname": "Marley", "username": "", "email": "bob@marley.de", "address": { "street": "Musterstraße 12", "city": "Erfurt", "zip": 99085 } }, "receiver": [ { "id": "564b3879e5feaed231000002", "createdAt": "2015-11-17T15:23:53.439+01:00", "updatedAt": "2015-11-17T15:23:53.439+01:00", "firstname": "Bob", "lastname": "Marley", "username": "", "email": "bob@marley.de", "address": { "street": "Musterstraße 12", "city": "Erfurt", "zip": 99085 } }, { "id": "564c87e1e5feae0e3a000001", "createdAt": "2015-11-18T15:14:57.081+01:00", "updatedAt": "2015-11-18T15:14:57.081+01:00", "firstname": "Bob", "lastname": "Marley", "username": "", "email": "bob@marley.de", "address": { "street": "Musterstraße 12", "city": "Erfurt", "zip": 99085 } } ], "text": "Hello!" } ], "pagination": { "first": "/api/message?limit=1&skip=0", "last": "/api/message?limit=1&skip=19", "previous": "", "next": "/api/message?limit=1&skip=1", "totalRecords": 20, "limit": 1, "pages": 20, "currentPage": 1 } }
*

func (*MessageController) Prepare

func (self *MessageController) Prepare()

type UserController

type UserController struct {
	// contains filtered or unexported fields
}

func (*UserController) Create

func (self *UserController) Create()

*

  • @api {post} /user Create User *
  • @apiName Create
  • @apiGroup User *
  • @apiVersion 0.0.1 *
  • @apiDescription Create a new user with the specified, required fields. *
  • @apiUse ErrorInternal * *
  • @apiParam {Object} user The user object with all required fields
  • @apiParam {String} user.email Users the email (used for login) <code>validation: email</code>
  • @apiParam {String} user.firstname Users firstname <code>minLen: 2 maxLen: 30</code>
  • @apiParam {String} user.lastname Users lastname <code>minLen: 2 maxLen: 30</code>
  • @apiParam {String} [user.username] Users nickname <code>minLen: 2 maxLen: 15</code>
  • @apiParam {Address} [address] User address object
  • @apiParam {String} [address.street] Street and Number
  • @apiParam {String} [address.city] City
  • @apiParam {Number} [address.zip] Zipcode
  • @apiParam {String} password The user password as plain text <code>minLen: 8 maxLen: 50</code> * *
  • @apiSuccess {Object} user The user object which was created. *
  • @apiSuccessExample {json} Success-Response
  • HTTP/1.1 201 Created
  • {
  • "user": {
  • "id": "5710ed60e5feae376f000001",
  • "createdAt": "2016-04-15T15:32:16.670823736+02:00",
  • "updatedAt": "2016-04-15T15:32:16.670823736+02:00",
  • "firstname": "Max",
  • "lastname": "Mustermann",
  • "username": "",
  • "email": "test@test.de",
  • "address": null
  • }
  • } *
  • @apiError MissingInvalidFields Some of the required fields are missing or invalid *
  • @apiErrorExample {json} Missing or invalid fields *HTTP/1.1 400 Bad Request *{
  • "error": {
  • "code": 400,
  • "message": "Bad Request",
  • "userInfo": [
  • {
  • "message": "Field 'firstname' is required."
  • },
  • {
  • "message": "Field 'lastname' is required."
  • },
  • {
  • "message": "Field 'email' is required."
  • },
  • {
  • "message": "Field 'password' is required."
  • }
  • ]
  • } *}

func (*UserController) GetAll

func (self *UserController) GetAll()

*

  • @api {get} /user Get All *
  • @apiName Index
  • @apiGroup User *
  • @apiVersion 0.0.1 *
  • @apiDescription Fetches all users *
  • @apiUse ErrorInternal *
  • @apiUse Pagination *
  • @apiSuccess {Array(User)} users The array of all users
  • @apiSuccess {String} users.id User ID
  • @apiSuccess {String} users.createdAt Timestamp of first creation
  • @apiSuccess {String} users.updatedAt Timestamp of last update
  • @apiSuccess {String} users.firstname Firstname
  • @apiSuccess {String} users.lastname Lastname
  • @apiSuccess {String} users.username Username
  • @apiSuccess {String} users.email Email
  • @apiSuccess {Address} address User address object
  • @apiSuccess {String} address.street Street and Number
  • @apiSuccess {String} address.city City
  • @apiSuccess {Number} address.zip Zipcode *
  • @apiSuccessExample {json} Success-Response
  • HTTP/1.1 201 Created
  • {
  • "pagination": {
  • "first": "/api/v1/users?skip=0&limit=10",
  • "last": "/api/v1/users?skip=0&limit=2",
  • "previous": "",
  • "next": "",
  • "totalRecords": 2,
  • "limit": 10,
  • "pages": 1,
  • "currentPage": 1
  • },
  • "users": [
  • {
  • "id": "55e961ab113c61d6d3000001",
  • "createdAt": "2015-09-04T11:17:31.219+02:00",
  • "updatedAt": "2015-09-08T16:35:44.484+02:00",
  • "firstname": "Max",
  • "lastname": "Mustermann",
  • "username": "zebresel_admin",
  • "email": "admin@zebresel.com",
  • "address": {
  • "street": "Musterstraße 12",
  • "city": "Erfurt",
  • "zip": 99085
  • }
  • },
  • {
  • "id": "55e9621d113c61d6d3000002",
  • "createdAt": "2015-09-04T11:19:25.83+02:00",
  • "updatedAt": "2015-09-04T11:19:25.83+02:00",
  • "firstname": "Max",
  • "lastname": "Musterfrau",
  • "username": "moehlone",
  • "email": "hello@zebresel.com",
  • "address": {
  • "street": "Musterstraße 12",
  • "city": "Erfurt",
  • "zip": 99085
  • }
  • }
  • ]
  • } *

func (*UserController) Prepare

func (self *UserController) Prepare()

Jump to

Keyboard shortcuts

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