Created
March 9, 2011 08:20
-
-
Save dahlia/861872 to your computer and use it in GitHub Desktop.
Narusegawa, a micro web framework in Naru
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
import narusegawa | |
app := narusegawa Application() | |
app get("/", fun | |
return "Hello world!" | |
end) |
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
use naru | |
Application(var routes = []) := class | |
ready(method, path, function) := fun | |
pattern := PathPattern(path) | |
route := Route(method, pattern, function) | |
self routes append(route) | |
end | |
get(path, function) := fun | |
self ready(:get, path, function) | |
end | |
post(path, function) := fun | |
self ready(:post, path, function) | |
end | |
put(path, function) := fun | |
self ready(:put, path, function) | |
end | |
delete(path, function) := fun | |
self ready(:delete, path, function) | |
end | |
end | |
Route(method, pattern, function) := class <- (method, pattern, function) | |
method := * | |
method get := fun -> self #0 | |
pattern := * | |
pattern get := fun -> self #1 | |
function := * | |
function get := fun -> self #2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment