-
Import all dependencies with:
go get github.com/gorilla/mux
-
To run the application locally and test API on the browser:
go build gorilla-mux-with-unit-tests
followed bygo run gorilla-mux-with-unit-tests
Then, test the encrypt API: localhost:8080/api/encrpyt/abcd
Should return 400
HTTP code with message Requested string length should be greater than 8 characters
Now try with: localhost:8080/api/encrpyt/12345678
Then, test the decrypt API: localhost:8080/api/encrpyt/<encrypted string exactly as returned by the encrypt API>
If you give wrong encrypted string, the API would return HTTP code 422
with an Invalid Input
message.
-
To run all unit tests:
go test --cover
-
To run the APi in docker:
docker build -t encrpy-decrypt-gorilla-api:v1 .
followed bydocker run -it -p 8080:8080 encrpy-decrypt-gorilla-api:v1