Created
October 12, 2014 15:10
-
-
Save ThomasLocke/a79096f4a369d8c310c6 to your computer and use it in GitHub Desktop.
shelf.middleware.handlers.dart
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
library shelfmiddleware.handlers; | |
import 'headers.dart'; | |
import 'package:shelf/shelf.dart' as shelf; | |
import 'package:shelf_path/shelf_path.dart'; | |
shelf.Response app(shelf.Request request) { | |
final String myToken = getPathParameter(request, 'token'); | |
final String html = ''' | |
<h1>/app</h1> | |
<p>We welcome you here with your ${myToken} token!</p> | |
<p>why don't you go visit the <a href="/foo?token=${myToken}">/foo</a> resource?</p> | |
'''; | |
return new shelf.Response.ok(html, headers: textHtmlHeader); | |
} | |
shelf.Response foo(shelf.Request request) { | |
final String myToken = getPathParameter(request, 'token'); | |
final String html = ''' | |
<h1>/foo</h1> | |
<p>You've arrived at /foo with the ${myToken} token</p> | |
<p>Go <a href="/app?token=${myToken}">back</a></p> | |
'''; | |
return new shelf.Response.ok(html, headers: textHtmlHeader); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment