-
Records: https://getir-go-assigment.herokuapp.com/records
Returns:{ "code": 0, "msg": "Success", "records": [ { "createdAt": "2016-04-02T21:08:18.091Z", "key": "xlPSAiou", "totalCount": 4017 }, ... ] }
Code Means:
- 0: Success
- 1: Internal Server Error
- 2: Bad request
- 3: Method Not Allowed
Records with filter:
- Records with start date filter: https://getir-go-assigment.herokuapp.com/records?startDate=2015-10-14
- Records with end date filter: https://getir-go-assigment.herokuapp.com/records?endDate=2016-12-27
- Records with start date and end date filter: https://getir-go-assigment.herokuapp.com/records?startDate=2015-10-14&endDate=2016-12-27
- Records with min count filter: https://getir-go-assigment.herokuapp.com/records?minCount=40
- Records with max count filter: https://getir-go-assigment.herokuapp.com/records?maxCount=3000
- In memory get: https://getir-go-assigment.herokuapp.com/in-memory?key=getir
-
In memory post: https://getir-go-assigment.herokuapp.com/in-memory
Request body:
type InMemory struct { Key string `json:"key"` Value string `json:"value"` }
- In memory sqlite get: https://getir-go-assigment.herokuapp.com/in-memory?key=getir
-
In memory sqlite post: https://getir-go-assigment.herokuapp.com/in-memory
Request body:
type InMemory struct { Key string `json:"key"` Value string `json:"value"` }
-
https://getir-go-assigment.herokuapp.com/records
This route returns records. Route takes 4 parameters.
-
startDate=YYYY-MM-DD (optional)
If startdate exist, returns records which creation date is greater than the start date.
Example route: https://getir-go-assigment.herokuapp.com/records?startDate=2015-10-14
-
endDate=YYYY-MM-DD (optional)
If endDate exist, returns records which creation date is smaller than the end date.
Example route: https://getir-go-assigment.herokuapp.com/records?endDate=2016-12-27
-
minCount=number (optional)
If minCount exist, returns records which sum counts is greater than the min count.
Example route: https://getir-go-assigment.herokuapp.com/records?minCount=40
-
maxCount=number (optional)
If maxCount exist, returns records which sum counts is smaller than the max count.
Example route: https://getir-go-assigment.herokuapp.com/records?maxCount=3000
-
startDate=YYYY-MM-DD (optional)
-
https://getir-go-assigment.herokuapp.com/in-memory
This route has two methods. GET and POST.- GET
This route gets value from go-cache according to key.
If key is empty, returns 400 status code.
If key is not found, returns 404 status code.
If key is exist, returns 200 status code, key and value.
Example route: https://getir-go-assigment.herokuapp.com/in-memory?key=getir
- POST
This route keeps key and value in go-cache.
Attention! This route has validation method. Key and value is required!
If body cannot be read, returns 500 status code with error message.
If body cannot be bind to model, returns 500 status code with error message.
If validation condition is not true, returns 400 status code with validation errors.
If operation is succesful, returns 200 status code with request body.
Route :https://getir-go-assigment.herokuapp.com/in-memory
Request Body:type InMemory struct { Key string `json:"key"` Value string `json:"value"` }
- GET
-
https://getir-go-assigment.herokuapp.com/in-memory-sqlite
This route has two method. GET and POST.- GET
This route gets value from sqlite-cache according to key.
If key is empty, returns 400 status code.
If there is any error when it was taken from cache error, returns 500 status code with error message.
If key is not found, returns 404 status code.
If key is exist, returns 200 status code, key and value.
Example route: https://getir-go-assigment.herokuapp.com/in-memory-sqlite?key=getir
- POST
This route keeps key and value in sqlite-cache.
Attention! This route has validation method. Key and value is required!
If body cannot be read, returns 500 status code with error message.
If body cannot be bind to model, returns 500 status code with error message.
If validation condition not true, returns 400 status code with validation errors.
If operation is successful, returns 200 status code with request body.
Route: https://getir-go-assigment.herokuapp.com/in-memory-sqlite
Request Body:type InMemory struct { Key string `json:"key"` Value string `json:"value"` }
- GET
-
cache
This folder holds files which contain cache(in-memory) structure and methods.
There are 2 cache(in-memory) structures.
- go-cache
- sqlite -
cmd
This folder contains main function.
The project starts with this function.
This function calls database connection, caches initialization, route setup and http server starts functions. -
database
This folder contains mongodb database client, connect and disconnect function. -
handlers
This folder holds files containing functions to process requests. -
model
This folder holds files containing the models required for the project. -
router
This folder contains route definition function. -
service
This folder contains database operations functions. -
test
This folder contains files containing test functions.