Last active
August 11, 2016 03:13
-
-
Save hnry/055e4e95e9f8314699dd6a12b37b0be3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {adapter, redirect, response} = require("spirit").node | |
const route = require("spirit-router") | |
const redirector = () => { | |
if (true) { | |
return redirect("/another_page") | |
} | |
// both returns are equal below, can use some helper functions for creating | |
// a response, just like redirect() will create a redirect response | |
return response("Condition failed, didn't redirect") | |
// return "Condition failed, didn't redirect" | |
} | |
const app = route.define([ | |
route.get("/", [], redirector), | |
route.get("/another_page", "Hi from another page") | |
]) | |
const http = require("http") | |
http.createServer(adapter(app)).listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment