challenge link: https://github.com/fetch-rewards/receipt-processor-challenge
-
After downloading, run
go run main.go.
note: you may need to install google/uuid by running:go get github.com/google/uuid
you may also need to install gorilla/mux by running:go get github.com/gorilla/mux -
This will start running the server in localhost port
:8080 -
Below I've provided two different ways to test below:
- using Postman
- using Rest Client plugin in VSCode
This method is to use Postman to help test the API.
- Create a
POSTrequest with the path:localhost:8080/receipts/process - In the request body, choose JSON and add details of the receipt you would like to process.
EXAMPLE

- This should return a body containing an id (a uuid to be specific). Make sure you copy this value.
- Create a
GETrequest with the path:localhost:8080/receipts/{id}/points
note: replace{id}with the id value copied in step 3 above. - This should return a body containing the number of points corresponding to the receipt with the id you wrote in the request.
EXAMPLE

This VSCode plugin will make it so you can test in VSCode with the file examples.rest provided.

- Above the
POSTrequest, there is a small, clickable text with the wordssend request. Clicking it will generate another window with the results of running the request. - This should return a body containing an id value. Make sure to copy this.
EXAMPLE

- On line 58 of the examples.rest file, there should be a
GETrequest that looks likeGET http://localhost:8080/receipts/{id}/points. - Replace
{id}value with the id value copied in step 2 above. - Above the
GETrequest, there is a small, clickable text with the wordssend request. Clicking it will generate another window with the results of running the request. - This should return a body containing the number of points corresponding to the receipt with the id you wrote in the request.
EXAMPLE

In case you make it this far:
- This is my first time coding in Go, but wanted to show you that I am open to learning new tools and languages!
- Of course, this is not something I could've done without any help. I followed a few tutorials on youtube to understand the concept of setting up webservers in Go (have uploaded that work to git as well in case you're curious!).
- References I used:
- https://github.com/david-youn/GO-SERVER/tree/main
reference video: https://www.youtube.com/watch?v=eqvDSkuBihs - https://github.com/david-youn/HTTP-SERVER
reference video: https://www.youtube.com/watch?v=5BIylxkudaE
Thanks for taking a look! Hope to hear back, David Youn
