So the core Irrigation service is designed to do a single thing: route incoming requests to a target service. A common rule in many routing layers is to rewrite requests from HTTP to HTTPS. Since Irrigation should not really be doing this I am going to bring up another service to do this.

Core Requirements

For idempotent requests such as GET and HEAD the service should issue permanent redirects to the same URI. For all other requests the service should issue a 405 Method Not Allowed.

Implementation

Now for a big question: how should I implement this? Since I am not doing any fancy routing I am really tempted to just go with the plain HTTP library in NodeJS. Going with Express does not provide any particular value on the redirect plane because we are just sending a redirect or method not allowed.

junk-drawer is totally going to be used here.

Simple to implement via the http module. Turns out one needs to add simple: false to the request-promise modules to prevent status codes other than the 200 series from failing. followRedirect: false also solves the problem of actually failing.