Quote Database in Go
- http://robfig.github.io/revel/
- https://github.com/mattn/go-sqlite3
- working sqlite3 library
revel run github.com/PacketFire/goqdb
Name | Type | Description |
---|---|---|
QuoteId | int | The quote id |
Quote | string | The quote body |
Author | string | The author of the quote |
Created | int64 | unix time in seconds |
Rating | int | The quote's rating |
Tags | []string | An array of tag strings, white space is trimmed from either side |
All resources return 200 on success or 500 with an undefined body if fatal errors were encountered. Resources requiring an id return a 404 with undefined body if the id does not exist in the database.
Quotes from the current year
GET /api/v0
Year:
GET /api/2010
Month:
GET /api/2010/7
Day:
GET /api/v0/2010/7/1
POST /api/v0
Accepts Quote, Author and Tags fields of a QdbView
Note: POST returns 201 Created on success and 400 Bad Request if the post data did not pass validation
Request:
POST /api/v0/ HTTP/1.1
Content-Type: application/json
Content-Length: 58
{"Quote": "test", "Author": "jgr", Tags: ["foo", "bar"]}
Response:
HTTP/1.1 201 Created
Content-Length: 135
Content-Type: application/json
Date: Mon, 25 Nov 2013 16:11:28 GMT
Set-Cookie: REVEL_FLASH=; Path=/
Set-Cookie: REVEL_SESSION=64172d7dab5d922c6cdc2ca993e72647e3585d75-%00_TS%3A1387987888%00; Path=/; Expires=Wed, 25 Dec 2013 16:11:28 UTC
{
"QuoteId": 20,
"Quote": "test",
"Created": 1385395888,
"Rating": 0,
"Author": "jgr",
"Tags": [
"foo",
"bar"
]
}
:id is used here in place of the quote id for the target entry
GET /api/v0/:id/view
PUT /api/v0/:id/rating
DELETE /api/v0/:id/rating