cpan-testers / cpantesters-deploy

Deploy scripts and configuration file for CPANTesters servers
4 stars 0 forks source link

Create JSON error documents for JSON API reverse proxies #11

Open preaction opened 7 years ago

preaction commented 7 years ago

When the reverse proxy fails to contact the underlying host, it sends back an error page. This error page defaults to HTML, which is annoying since every other page that could be returned from this site is in JSON.

We should make a 502 error page that returns JSON that looks like the JSON returned by every other error:

{
    "errors": [
        { "message": "Timeout while contacting application server" }
    ]
}

We need to configure Apache to use this error page for the api.cpantesters.org and metabase.cpantesters.org sites (configuration files are in etc/apache2/vhost). The configuration should be sure to send the file with the correct Content-Type header to ensure clients treat it as JSON.