Skip to content

Commit

Permalink
format router
Browse files Browse the repository at this point in the history
Relates #56
  • Loading branch information
Parissai committed Mar 29, 2018
1 parent 15a984e commit f5d840d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
const {handleHome, handleLatest, handleStatic, handleSearch} = require("./handler");
const {
handleHome,
handleLatest,
handleStatic,
handleSearch
} = require('./handler');

const router = (request, response) => {
const url = request.url;
if (url === "/") {
if (url === '/') {
handleHome(request, response);
} else if (url === "/latest") {
} else if (url === '/latest') {
handleLatest(request, response);
} else if (url.indexOf("public") !== -1) {
} else if (url.indexOf('public') !== -1) {
handleStatic(request, response);
} else if (url.startsWith("/search")) {
} else if (url.startsWith('/search')) {
handleSearch(request, response);
} else {
response.writeHead(404, { "Content-Type": "text/html" });
response.end("Page not found");
response.writeHead(404, { 'Content-Type': 'text/html' });
response.end('Page not found');
}
};

Expand Down

0 comments on commit f5d840d

Please sign in to comment.