This project is a HTTP Mock Server, thought to support development of API Rest that don't have full implementation yet.
So you can use as a frontend developer to mock a server-side backend, or as a backend developer you can use to mock other microservice.
Route | Description |
---|---|
GET /_cat/routes |
List all routes |
Data Mock File: mock_data.json
{
"/register": { <--- Endpoint
"POST": { <--- HTTP Method
"$.request": { <--- Request
"$.body": { <--- Request Body
"name": "John Doe"
}
},
"$.response": { <--- Response
"$.status": 200, <--- HTTP Status Code
"$.body": { <--- Response Body
"person": {
"name": "John Doe",
"age": 30,
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
}
}
}
}
},
}
}
docker-compose up -d --build
cargo build -r && ./target/release/http_mock_server
cargo run
Example using cURL:
curl -v --request POST \
--url http://localhost:7878/register \
--header 'Content-Type: application/json' \
--data '{"name": "John Doe"}'
Terminal Output -verbose
:
* Connected to localhost (127.0.0.1) port 7878 (#0)
> GET /register HTTP/1.1
> Host: localhost:7878
> User-Agent: curl/7.85.0
> Accept: */*
> Content-Type: application/json
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Length: 107
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Accept-Ranges: bytes
<
* Connection #0 to host localhost left intact
{"address":{"city":"Anytown","state":"CA","street":"123 Main St","zip":"12345"},"age":30,"name":"John Doe"}
sequenceDiagram
Request->>+Controller: request
Controller->>+Service: request
Service->>+[Mock File]: read
[Mock File]->>-Service: mock line
Service->>-Controller: response
Controller->>-Request: response