1.0.9 • Published 4 years ago

http-reqtrace v1.0.9

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
4 years ago

npm version license downloads docker-image-version docker-image-size docker-pulls

http-reqtrace

Description

The application starts a Web server which logs details of all incoming HTTP requests such as:

  • HTTP Method & URL
  • Query params
  • Headers
  • Body

The application accepts all HTTP methods and URIs. The routing is defined like this:

  • /status/:statusCode : return an HTTP response with status code statusCode and body {"message":"OK|KO"}
  • /**/* : return an HTTP response with status code 200 OK and body {"message":"OK"}
  • /metrics : return Prometheus metrics regarding HTTP requests

Following query parameters are also supported:

  • ?latencyInMs=60000 : wait for the given period in milliseconds before responding.

This service can be used to :

  • See very quickly what are the requests received and inspect their content.
  • Have a quick way to simulate specific cases with particular HTTP response codes.

How to use

Starts the service

  • Run container as root:
$ docker run -ti --name http-reqtrace -p 80:80 julb/http-reqtrace:latest
  • Run container as non-root:
$ docker run -ti --name http-reqtrace -p 80:8080 -e PORT=8080 -u 65534:65534 julb/http-reqtrace:latest

Note: the PORT environment variable can be set to customize listening port.

Request the service with any method, URI and parameters

$ curl http://localhost/context/uri?param1=value1&param2=value2 -H "Authorization: Bearer jwt"
{"statusCode": 200,"message":"OK"}
http > [ GET ] HTTP/ 1.1   http://localhost/context/uri?param1=value1&param2=value2
http >>     Header :  host : localhost
http >>     Header :  user-agent : curl/7.54.0
http >>     Header :  accept : */*
http >>     Header :  authorization : Bearer jwt
http >>     Query  :  { param1: 'value1', param2: 'value2' }
http >>     Body   :  {}
http < [ HTTP 200 ]

Getting specific HTTP responses status codes

$ curl http://localhost/status/404 -H "Authorization: Bearer jwt"
{"statusCode":404,"message":"KO"}

$ curl http://localhost/status/500 -H "Authorization: Bearer jwt"
{"statusCode":500,"message":"KO"}
http > [ GET ] HTTP/ 1.1   http://localhost/status/404
http >>     Header :  host : localhost
http >>     Header :  user-agent : curl/7.54.0
http >>     Header :  accept : */*
http >>     Header :  authorization : Bearer jwt
http >>     Query  : {}
http >>     Body   : {}
http < [ HTTP 404 ]
http > [ GET ] HTTP/ 1.1   http://localhost/status/500
http >>     Header :  host : localhost
http >>     Header :  user-agent : curl/7.54.0
http >>     Header :  accept : */*
http >>     Header :  authorization : Bearer jwt
http >>     Query  : {}
http >>     Body   : {}
http < [ HTTP 500 ]

Simulate latency

$ curl http://localhost/status/504?latencyInMs=60000
{"statusCode":504,"message":"KO"}
http > [ GET ] HTTP/ 1.1   http://localhost/status/504
http >>     Header :  host : localhost
http >>     Header :  user-agent : curl/7.54.0
http >>     Header :  accept : */*
http >>     Query  : {}
http >>     Body   : {}
<60s waiting...>
http < [ HTTP 504 ]
1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

0.0.0

5 years ago

1.0.0

5 years ago