Golang REST App Demo
Project Description
A simple REST application using Golang that I created as a practice exercise.
Project Details
Data imported from GitHubProject Readme
Readme content imported from GitHubREADME
This repository is modeled loosely after a practice exercise I came across. As a Node.js developer, I did the task in Node, but I would like to learn Golang. This seemed like a perfect opportunity to leverage my REST experience so that I could learn Golang.
The task is to do the following:
- [x] An endpoint where users can leave feedback for a specific game session
- [x] A user can only submit one review per game session
- [x] User MUST leave a rating of 1-5 if providing feedback
- [x] User MAY add a comment when providing feedback
- [x] Multiple players can rate the same session
- [x] Folloing RESTful principles, create HTTP endpoints to allow:
- [x] Players to add feedback for a session
- [x] Ops team members to see recent feedback left by players
- [x] Allow filtering by rating
- [x] Include a README that includes at least the following:
- [x] API Documentation
- [x] Instructions for launching and testing your API locally (if not the built-in scripts)
- [ ] Bonus items
- [ ] A simple front-end
- [ ] Tests
- [ ] Deployment scripts/tools
- [ ] Authentication
- [ ] User permissions
Testing
Starting the service locally
- Run
make all
- Run
make run
- Begin testing
Schema changes
Whenever you have a schema change (e.g., whenever you add/remove, or otherwise update gorm models), you will likely run into issues when starting the service. This is most-likely a result of the schema no longer matching that of the one that exists within the
test.db
file.The fastest way around this is to simply delete the
test.db
file and re-runmake run
, which will generate a newtest.db
file with the new schema. At this point, the project should build successfully.
API Documentation
Creating test resources
- User
- Send
POST
to/users/create
- Does not require a post-body
- Send
- Session
- Send
POST
to/sessions/create
- Send
- SessionFeedback
- Send
POST
to/sessions/feedback/create
- Pass the following parameters in the POST body:
sessionId
: the UUID of the Session being revieweduserId
: the UUID of the user posting the feedbackrating
: the rating for the Session (1-5)- (optional)
comment
: Optional comment for the feedback
- Send
Querying resources
- Get all users
- Send
GET
to/users
- Send
- Get Sessions
- Send
GET
to/sessions
- Send
- Get Session feedback
- Send
GET
to/sessions/feedback
- To get all feedback for a given session, send
GET
to/sessions/feedback?sessionId=<SESSION_ID>
- To get all feedback with a given rating, send
GET
to/sessions/feedback?rating=<RATING>
- To get all feedback for a given session with a given rating, send
GET
to/sessions/feedback?sessionId=<SESSION_ID>&rating=<RATING>
- Send