Creating mock server
moclojer uses the specifications written in the configuration file to declare the endpoints, uri parameters, and its return (which can be dynamic with the data received in the request)
Create a file named moclojer.yml
(we will use yaml because it is a more familiar format to most people, k8s did a great job diseminating this format), inside the yaml file created put the following content:
Swagger
Describing all endpoints declared in the configuration file, you can see the following.
/hello/:username
GET
/hello/:username
Will take a parameter from the url called username and return the username dynamically from the response body.
Path Parameters
username*
string
/hello-world
GET
/hello-world
Static endpoint that returns content that is not dynamic.
/with-params/:param1
GET
/with-params/:param1
It will take a parameter from the url called param1 and the query string called param1, and return both parameters dynamically in the response body. Exemplifying how to consume the two types of parameters in the return from the endpoint.
Path Parameters
param1*
string
Query Parameters
param1*
string
/first-post-route
POST
/first-post-route
It will take a parameter from the body called project, and return the project name dynamically from the response body.
Request Body
project*
string
Last updated