Skip to content

askrella/go-mockserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go MockServer

License: MIT Docker Docker AMD64 Docker ARM64 Build

Askrella

A tiny (< 5mb) implementation of a request capturing proxy written in Golang. Used internally at Askrella for mocking external partners in our CI pipelines and sometimes improving compression and loading times for CSV datasets.

Why?

We at Askrella sometimes encounter projects with minimal own logic rather than gluing multiple APIs together and process their data. In these cases we had troubles with the response times these APIs offer (> 3.5s, rare cases even > 1,4min). Since we want to run extensive tests against these providers in our pipeline, we need some kind of proxy capturing and mocking these providers in our pipeline.

On our search we encountered MockServer written in Java, but the functionality was way to extensive and the images too big for fast iterations in our scenarios (possibly dozens of different APIs on a small CI/CD pipeline).

Of course we don't offer the same functionality as the big brothers, but we kept it simple and our images minimal (< 10mb)! The code itself doesn't need many dependencies and only relies on the Go standard library as well as some curated compression libraries (e.g. brotli). Our final container is based on distroless.

⚙️ Getting Started

Run the mockserver using docker compose:

version: '3'

services:
  mock:
    build: .
    environment:
      MOCK_TARGET: https://google.com 
      # MOCK_PORT: 80 # The port MockServer shall bind to
      # MOCK_HOST: 0.0.0.0 # The interface MockServer shall use
      # CACHE_ENABLED: true # Whether responses to requests shall be cached and re-delivered similar requests
      # RECOMPRESS: true # When enabled the upstream (external server) response body will be decompressed and compressed
                         # using gzip level 9 compression. Depending on the upstream, this can lead to extremely reduced
                         # request times.
    ports:
      - "8080:80/tcp"

Note: Google actually doesn't work (404) because the request currently won't be manipulated accordingly.

👋 Contributors

Feel free to open a new pull request with changes or create an issue here on GitHub! :)

⚠️ License

Distributed under the MIT License. See LICENSE.txt for more information.

Bugs?

Since I coded most of the code at the airport, please let us know if you encounter some kind of bug. :)

🤝 Contact Us

In case you need professional support, feel free to contact us