mendhak / docker-http-https-echo

Docker image that echoes request data as JSON; listens on HTTP/S, useful for debugging.
https://code.mendhak.com/docker-http-https-echo/
MIT License
621 stars 136 forks source link

Pass response status code via query string or path #32

Closed mac2000 closed 2 years ago

mac2000 commented 2 years ago

Will be nice if it will be possible to pass response code not only by HTTP headers but by query string or path

Motivation: at moment I'm playing with nginx ingress, in its annotations I can pass URL only nothing else 🤷‍♂️

Seems like it will require really small change here, something like:

const setResponseStatusCode = parseInt(req.headers["x-set-response-status-code"] || req.query["x-set-response-status-code"], 10)
mendhak commented 2 years ago

Yes thanks, that was a small change. I also added the same feature for response delay as well.

I've got a tag if you want to test this: docker pull mendhak/http-https-echo:issue32-querystring

mac2000 commented 2 years ago

Yey, indeed it works, thank you

BTW: offtop, its morning and my bad, I did tried:

docker run -it --rm -p 8080:80 mendhak/http-https-echo:issue32-querystring

and was unable to figure out why nothing works 🤷‍♂️

only after a cup of coffee, I realized that I am using the wrong port

missing console.log('listening 0.0.0.0:8080') leads to such scenarios, I mean that container started but does not say anything at all which makes it not clear if everything ok or not

mendhak commented 2 years ago

Yeah actually I was mulling that the other day. It'll be good to add something like "I'm listening..."

mendhak commented 2 years ago

Done, I've pushed tag mendhak/http-https-echo:22 that also includes a listening message at the beginning.