This example microservice exposes two REST endpoint over HTTP. These endpoints are available at localhost:5678/ping and localhost:5678/count upon starting the service. The functionality exposed by these endpoints is explained below.
The /ping endpoint simply returns the following JSON:
{
"msg": "pong"
}The /count endpoint returns JSON with a single "count" property which starts at zero and increases by one with each successive request. This should technically be a POST request because in order to be a true REST API, all GET requests should be idempotent, but it has been exposed as a GET request for ease of testing.
Here's an example response for this endpoint:
{
"count": 5
}- Install nodejs and npm at https://nodejs.org if you don't already have it
- Clone the repository with
git clone https://github.com/galactus-player/exemplar - Run
npm startin the root of the cloned repo - Visit
localhost:5678/pingorlocalhost:5678/countin a web browser