Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Setting up handling for a bad route.
Browse files Browse the repository at this point in the history
  • Loading branch information
tizzo committed Sep 4, 2014
1 parent 680f160 commit bc42a7f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
12 changes: 12 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,18 @@ function proxyRoute(req, res, next) {
logger.info(string, user, req.connection.remoteAddress, originalReq, newRequest);

// Proxy the request and response.
proxy.on('error', function(error) {
var message = 'There was an error proxying to the backend.';
logger.error(message, route.name);
// TODO: Should this be in `lib/routes.js`?
var options = {
name: config.name,
imageURL: config.imageURL,
imageAlt: config.imageAlt,
error: error,
};
res.render('bad-route', options);
});
proxy.web(req, res, {
target: {
host: route.host,
Expand Down
26 changes: 21 additions & 5 deletions views/bad-route.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Smithers</title>
<title><%= name %></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Login to our proxy">
<meta name="author" content="Zivtech, LLC">
Expand All @@ -21,13 +21,29 @@

<body>

<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
</a>
<a class="brand" href="#"><%= name %></a>
<a class="brand" href="/proxy-logout">Logout</a>
</div>
</div>
</div>

<div class="container">
<div class="grid">
<div class="row-fluid">
<div class="smithers span4">
<img src="/Waylon_Smithers.png">
</div> <!-- /smithers -->
</div> <!-- /row -->
<div class="message span8">
<h1>Bad Route</h1>
<p>The request could not be completed. This route may be misconfigured or the backend service may be down.</p>
<p>Error encountered: <code><%= error.message %></code></p>
</div><!-- /message -->
<div class="image span4">
<img src="<%= imageURL %>" alt="<%= imageAlt %>">
</div> <!-- /image -->
</div> <!-- /row-fluid -->
</div> <!-- /grid -->
</div> <!-- /container -->

Expand Down

0 comments on commit bc42a7f

Please sign in to comment.