Simple HTTP server for proxying HTTP-requests to 3rd-party services.
Make sure sure you have installed Go
at least versino 18.1.
- First timee call
go mod tidy
in order to install all required packages added to project
By default app will run on port 8080
. If you want to choose other port then execute go run
command with port
argument as in example shown below, otherwise omit -port
argument.
go run main.go -port <any port>
- minor
ping
<->pong
route added. - HTTP Api with 2 routes.
-
/proxy
-
/proxy/history
-
- demonstrated how concurently track requests. See request_tracker in observer package
-
domain
&observer
packages are covered with unit tests. See*test.go
files in the corresponding packages - API layer covered with unit tests. See
api > proxy > api_test.go
api_test.go - graceful shutdown logic implemented. See Start() in server.go in api package
cURL samples can be run from command line
curl --request GET 'http://localhost:8080/ping'
curl --request GET 'http://localhost:8080/proxy' \
--header 'Content-Type: application/json' \
--data-raw '{
"method": "GET",
"url": "http://yandex.com",
"headers": {
"Authentication": ["Basic bG9naW46cGFzc3dvcmQ="]
}
}
'
curl --request GET 'http://localhost:8080/proxy/history'