Skip to content

Instantly share code, notes, and snippets.

@dahlia
Created March 9, 2011 08:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dahlia/861872 to your computer and use it in GitHub Desktop.
Save dahlia/861872 to your computer and use it in GitHub Desktop.
Narusegawa, a micro web framework in Naru
import narusegawa
app := narusegawa Application()
app get("/", fun
return "Hello world!"
end)
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