Created
February 25, 2012 21:39
-
-
Save pedrofaria/1910984 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 std; | |
import web; | |
Map<String, String> routes_get; | |
Int registerGet(String url, String callback) { | |
routes_get.insert(url, callback); | |
} | |
Int checkRoutes() { | |
String path = web.request::param('q'); | |
Array<String> routes_re = routes_get.getKeys(); | |
Array<String> routes_cb = routes_get.getValues(); | |
for (Int i = 0; i < routes_re.size(); i++) { | |
Regex reg(routes_re[i]); | |
if (reg.matches(path)) { | |
println('found'); | |
ReflectionFunction f( routes_cb[i] ); | |
f.call(); | |
return 1; | |
} | |
} | |
println('not found'); | |
return 0; | |
} | |
Int run() { | |
web.session::header(); | |
checkRoutes(); | |
} |
This file contains hidden or 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
#!/Users/eu/src/clever/clever | |
import std; | |
import 'cleverfw.clv' as fw; | |
Void cb_home() { | |
println('ENTROU AKI!'); | |
} | |
fw::registerGet("^home$", 'cb_home'); | |
fw::registerGet("^opa$", 'cb_home'); | |
fw::run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment