Simple server for REST API and message queue mocks
With our service you can
- Create REST API mocks - set up route with either of three handlers:
- Static mocks: request on route will respond with the predefined body
- Proxy mocks: request on route will be proxied to the external service forwarding all request headers and body
- Dynamic mocks: request on route will launch the predefined python script accepting request headers and body as its arguments
- Create messages queues mocks - set up broker queue mock or link two queues in an ESB pair:
- Rabbitmq mocks: you can send messages to the writing end of the mocked queue and read messages from the reading one
- Kafka mocks: same as previous but instead of Rabbitmq queues you are mocking the Kafka topics
- ESB: you can connect two existing queues together, send messages to the first queue and read them from the second
The service can be used through the REST API or through mock-server-front ReactJS UI
mock-server is implied to be deployed locally on your machine
You need to install and run docker-daemon on your computer. Also, install golang (in future versions, that step will be discarded)
In Linux machine the only thing you should do is to run the deploy.sh script
$ git clone git@github.com:Michicosun/mock-server.git
$ cd mock-server/deploy
$ chmod +x deploy.sh
$ ./deploy.sh
Script sets up the system-daemon
service mock-server.service
and runs the nginx
web-server
If everything went well, you'll see
Mock server successfully deployed and running. Available on http://your-hostname.domain
Deploy script uses the systemd
Linux service manager and Linux command line commands, so currently automatic deploy is unavailable. But it is possible to deploy the service manually
- run the message queue brokers docker containers with
$ cd deploy && docker compose up -d
- init the golang packages executing
$ go mod init
- run the service
$ go run cmd/server/main.go
To configure the service components (e.g. adjust the broker's configuration or change the default service port) you can modify the service config
- All configs are locating in configs/ dir. Adjust them for your needs
- Executable files lay in cmd/
- deploy/ dir consists of deploy scripts and systemd, docker and nginx config files
- Service components implementation locates in internal/
- internal/server: HTTP server implementation based on gin web framework
- internal/database: MongoDB connect and database interface
- internal/brokers: Rabbitmq and Kafka connectors and ESB
- internal/coderun: Docker workers that executes python scripts + watcher that distributes requests between theme + docker-provider that serve the docker containers
- internal/control: Control service
- internal/util: Support classes (e.g. blocking queue, file storage connector)
Examples of mock-server usage can be found either in cmd/playground directory or in tests