Skip to content

Instantly share code, notes, and snippets.

@olivernn
Created June 26, 2012 08:40
Show Gist options
  • Save olivernn/2994436 to your computer and use it in GitHub Desktop.
Save olivernn/2994436 to your computer and use it in GitHub Desktop.
var app = Davis(function () {
this.configure(function () {
this.linkSelector = 'nav a'
this.formSelector = 'nav form'
})
this.get('/', function (req) {
showHomePage()
})
this.get('/pay-bill', function (req) {
showPayBillPage()
})
this.get('/send-money', function (req) {
showSendMoneyPage()
})
this.get('/contact-us', function (req) {
showContactPage()
})
this.get('/about-us', function (req) {
showAboutPage()
})
this.get('/blog', function (req) {
showBlog()
})
this.post('/search', function (req) {
loadSearchResults(req.params['query'])
})
})
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/pay-bills">Pay Bills</a></li>
<li><a href="/send-money">Send Money</a></li>
<li><a href="/contact-us">Contact Us</a></li>
<li><a href="/about-us">About Us</a></li>
<li><a href="/blog">Blog</a></li>
<li>
<form action="/search" method="post">
<input type="search" name="query" placeholder="Search…"></input>
</form>
</li>
</ul>
</nav>
@moduor
Copy link

moduor commented Jun 26, 2012

Hi Oliver, don't you think I should do a POST so that the server knows how to respond?

@olivernn
Copy link
Author

Which route do you think should be a POST? The search could either be a POST or a GET, it really depends on your app to be honest. I think the navigation links should definitly be GET requests as they are links, but again this is depends on how your app works.

As long as the routes you define in Davis match how the server responds then you should be fine, so if without Davis those navigation links make get requests then they should be get requests in davis too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment