Blog Posts API
An API written in Go that fetches data from https://api.hatchways.io/assessment/blog/posts and allows sorting options in either descending or ascending order
Tech Stacks
Server: Go 1.18
Run Locally
Go to the project directory
cd BlogPostAPI
Install dependencies
go get -u github.com/gorilla/mux
go get -u github.com/patrickmn/go-cache
go get -u github.com/jarcoal/httpmock
Start the server
go run main.go
Make requests using the following base URL as instructed by the API reference
http://localhost:3000/
Running Tests
To run tests, run the following command
go test
API Reference
Ping API
GET /api/ping
Parameter | Type | Description |
---|---|---|
N/A |
N/A |
Test to ensure API is up and running |
Get posts
GET /api/posts/${id}
Parameter | Type | Description |
---|---|---|
tags |
string |
Required. Comma-separated tag list |
sortBy |
string |
Optional. “id”, “reads”, “likes”, “popularity” |
tags |
string |
Optional. “asc”, “desc” |