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 |
UserId | string | Author's user id hash |
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.
GET /api/v1
GET /api/v1/:id
id | return single entry |
tag | return quotes with tag |
search | search quotes |
from | date string in the form mm/dd/yyyy |
to | same as above |
sort | one of relevence, rating, date, random |
desc | boolean, sort in descending order |
size | maximum amount of entries to return, capped at 4096 by default |
POST /api/v1
Accepts Quote, Author and Tags fields of a Quote
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-Type: application/json
...
{
"QuoteId": 20,
"Quote": "test",
"Created": 1385395888,
"Rating": 0,
"Author": "jgr",
"Tags": [
"foo",
"bar"
]
}
PATCH /api/v1/:id/:typ
id | target id |
typ | one of up, down, delete |