Skip to content

Simple server for REST route and message queue mocks

Notifications You must be signed in to change notification settings

Michicosun/mock-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mock-server

Simple server for REST API and message queue mocks

Usage scope

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

Interface

The service can be used through the REST API or through mock-server-front ReactJS UI

Deploy

mock-server is implied to be deployed locally on your machine

Prerogatives

You need to install and run docker-daemon on your computer. Also, install golang (in future versions, that step will be discarded)

Linux deploy

In Linux machine the only thing you should do is to run the deploy.sh script

$ git clone [email protected]: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

Rest OS

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

Configuration

To configure the service components (e.g. adjust the broker's configuration or change the default service port) you can modify the service config

Service architecture

Architecture overview: arch

Examples

Examples of mock-server usage can be found either in cmd/playground directory or in tests

About

Simple server for REST route and message queue mocks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published