~genbyte/retstat

Simple HTTP server that responds with the status in the URL path
746035cc — Brad Alfirevic 19 days ago
Rewrite with tiny_http and default phrase in body
081e106d — Brad Alfirevic 2 months ago
Update readme
60d82fb6 — Brad Alfirevic 2 months ago
Fix warn unusued variable in 404 catch

clone

read-only
https://git.sr.ht/~genbyte/retstat
read/write
git@git.sr.ht:~genbyte/retstat

You can also use your local clone with git send-email.

retstat

Homepage: hub.sr.ht | Tickets: todo.sr.ht | crates.io

This program will return the status code to you. That is, in its HTTP response, the status code you pass in the URL will be used. The body of the response is the default phrasing for that code. If you pass a code that is unknown, "Unknown" will be the body.

retstat was born out of the desire to have a reliable source of status codes so I could test my shell scripts without hitting someone else's server so many times.

I have it live at https://genbyte.dev/status/, so some examples:

There is a very basic service file for systemd in the root of the source tree. It assumes the bin is at /usr/bin/retstat.

Configuration

There isn't much configuration available, as this small server doesn't do much. You can change the listening address with the -l cli option. The long option is --host, if you want to use that.

retstat defaults to listening on localhost:30210.

Below is the recommended configuration for Nginx. Thanks to this answer which taught me how to remove the path the proxy lives under from the path the proxy receives. What I mean is, if you visit https://genbyte.dev/status/200, retstat won't see /status/200 but /200 instead.

location = /status {
	return 302 /status/;
}

location /status/ {
	proxy_pass http://localhost:30210/;
}