A HTTP mole service

httpmole

Build Status

httpmole provides a HTTP mock server that will act as a mole among your services, telling you everything http clients send to it and responding them whatever you want it to respond. Just like an actual mole.

Features:

  • Use response-status and response-header to quickly spin up a http server.
  • Use response-file to modify the response in real time using a text editor.
  • Use response-from to act as a proxy and be able to inspect the request/response going to a given service.

Install

go install github.com/jcchavezs/httpmole/cmd/httpmole

Usage

Using the binary

httpmole -p=8082 -response-status=200

or using a response file:

httpmole -p=8082 -response-file=./myresponse.json
// myresponse.json
{
    "status_code": 200,
    "headers": {
        "content-type": "application/json"
    },
    "body": {
        "message": "I am real"
    }
}

or proxying a service to inspect the incoming requests:

httpmole -p=8082 -response-from=therealservice:8082

Using docker

docker run -p "10080:10080" jcchavezs/httpmole -response-status=201

or pass a response file over volumes

docker run -p "10080:10080" -v `pwd`/response.json:/httpmole/response.json jcchavezs/httpmole -response-file=/httpmole/response.json

Docker image is hosted in dockerhub

httpmole is heavily inspired by httplab

Owner
José Carlos Chávez
Software engineer, Zipkin team member and Peruvian llama ambassador. Read me at https://medium.com/devthoughts
José Carlos Chávez
Similar Resources

Idiomatic HTTP Middleware for Golang

Negroni Notice: This is the library formerly known as github.com/codegangsta/negroni -- Github will automatically redirect requests to this repository

Jan 2, 2023

A tiny http middleware for Golang with added handlers for common needs.

rye A simple library to support http services. Currently, rye provides a middleware handler which can be used to chain http handlers together while pr

Jan 4, 2023

A collection of useful middleware for Go HTTP services & web applications 🛃

gorilla/handlers Package handlers is a collection of handlers (aka "HTTP middleware") for use with Go's net/http package (or any framework supporting

Dec 31, 2022

Simple middleware to rate-limit HTTP requests.

Tollbooth This is a generic middleware to rate-limit HTTP requests. NOTE 1: This library is considered finished. NOTE 2: Major version changes are bac

Dec 28, 2022

OpenID Connect (OIDC) http middleware for Go

Go OpenID Connect (OIDC) HTTP Middleware Introduction This is a middleware for http to make it easy to use OpenID Connect. Currently Supported framewo

Jan 1, 2023

Hex - Expectations for HTTP handlers

Hex is a simple wrapper that extends httptest.Server with an expectation syntax, allowing you to create mock APIs using a simple and expressive DSL:

Aug 9, 2021

Statigz serves pre-compressed embedded files with http in Go

statigz statigz serves pre-compressed embedded files with http in Go 1.16 and later. Why? Since version 1.16 Go provides standard way to embed static

Dec 24, 2022

A Concurrent HTTP Static file server using golang .

A Concurrent HTTP static server using Golang. Serve Static files like HTML,CSS,Js,Images,Videos ,ect. using HTTP. It is Concurrent and Highly Scalable.Try now!

Dec 19, 2021

Go HTTP middleware to filter clients by IP

Go HTTP middleware to filter clients by IP

Oct 30, 2022
Comments
  • Pretty print when using JSON body

    Pretty print when using JSON body

    When serving a JSON body, for example:

    {
        "status_code": 200,
        "headers": {
            "content-type": "application/json"
        },
        "body": {
            "message": "I am real"
        }
    }
    

    The HTTP response body has an unlikely indentation:

    {
            "message": "I am real"
        }
    

    Prettify the JSON bodies before writing it to the body.

  • feat: adds support for log filtering.

    feat: adds support for log filtering.

    This PR adds:

    - Use `log-response` to log the response along with the request in the stdout.
    - Use `log-filter-method` to log only matching method e.g. `"GET|DELETE"`.
    - Use `log-filter-path` to log only matching path e.g. `"/subjects"`.
    
  • Should we allow to start the server even if the response file does not exist?

    Should we allow to start the server even if the response file does not exist?

    The response-file allows users to use a JSON file for declaring the response from the server. Currently we check if the file exists before starting the server and fail if it does not exist.

    In one hand once we start the server we ready to receive traffic and we should be guarantee on start up that we are ready to do so. In the other hand, there is a difference between being up and being available and hence it is possible we could launch the container even before the file exists.

    The technical implications of a potential change are really low.

  • Adds support for wait functionality

    Adds support for wait functionality

    Currently httpmole can't wait until the actual service is up, hence failing on response with a 502. We could either wait to serve and let clients to retry or expect the clients to retry.

Mahi is an all-in-one HTTP service for file uploading, processing, serving, and storage.
Mahi is an all-in-one HTTP service for file uploading, processing, serving, and storage.

Mahi is an all-in-one HTTP service for file uploading, processing, serving, and storage. Mahi supports chunked, resumable, and concurrent uploads. Mahi uses Libvips behind the scenes making it extremely fast and memory efficient.

Dec 29, 2022
HTTP/2 Apple Push Notification service (APNs) provider for Go with token-based connection

APNs Provider HTTP/2 Apple Push Notification service (APNs) provider for Go with token-based connection Example: key, err := apns.AuthKeyFromFile("Aut

Dec 29, 2022
A dead simple, stupid, http service.

A dead simple, stupid, http service implemented in a complicated way just for the sake of following Go design patterns and scalability. Useful for learning and testing basic kubernetes networking. Made on an insomniac night.

Sep 2, 2022
A http service to verify request and bounce them according to decisions made by CrowdSec.

traefik-crowdsec-bouncer A http service to verify request and bounce them according to decisions made by CrowdSec. Description This repository aim to

Dec 21, 2022
Link converter service converts URLs to deeplinks or deeplinks to URLs.

Link converter Link converter service converts URLs to deeplinks or deeplinks to URLs. The service responds to the incoming request and first checks w

Dec 23, 2021
Composable chains of nested http.Handler instances.

chain go get github.com/codemodus/chain Package chain aids the composition of nested http.Handler instances. Nesting functions is a simple concept. I

Sep 27, 2022
Go http.Hander based middleware stack with context sharing

wrap Package wrap creates a fast and flexible middleware stack for http.Handlers. Features small; core is only 13 LOC based on http.Handler interface;

Apr 5, 2022
Minimalist net/http middleware for golang

interpose Interpose is a minimalist net/http middleware framework for golang. It uses http.Handler as its core unit of functionality, minimizing compl

Sep 27, 2022
Add interceptors to GO http.Client

mediary Add interceptors to http.Client and you will be able to Dump request and/or response to a Log Alter your requests before they are sent or resp

Nov 17, 2022
Lightweight Middleware for net/http

MuxChain MuxChain is a small package designed to complement net/http for specifying chains of handlers. With it, you can succinctly compose layers of

Dec 10, 2022