Based on Thomas Watson's http-echo-server
This will create either a HTTP or HTTPS server. The npm run start
script takes care of creating a self-signed certificate to make things easier.
It replies with the configured HTTP Code(or 200 as a default) and prints the body of the request as well as the URL and Method used.
Execute npm install
as usual.
Just curl the URL of the app:
# When using HTTP: GET
curl http://localhost:56537/trying/out/the/url
# When using HTTPS: GET request that accepts the self-signed certificate
curl -k https://localhost:56537/trying/out/the/url
# When using HTTP: POST request
curl http://localhost:56537/trying/out/the/url -d "{ \"data\": \"tests\" }"
# When using HTTP: POST request that accepts the self-signed certificate
curl -k https://localhost:56537/trying/out/the/url -d "{ \"data\": \"tests\" }"
TODO:
- Add documentation on how to start in HTTPS mode;
- Add documentation on how to set up the port;
- Add documentation on how to set up the HTTP Code;