Created
July 6, 2010 00:14
-
-
Save jacksonh/464836 to your computer and use it in GitHub Desktop.
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
using Mango; | |
using Mango.Templates.Minge; | |
namespace MangoProject { | |
public class MangoProject : MangoApp { | |
public override void OnStartup () | |
{ | |
// Tell the template system where the templates are located. | |
Templates.Initialize ("templates/"); | |
// | |
// The startup handler is called when the module is first | |
// started, it can be used to initialize handlers: | |
// This is a handler for an HTTP GET method for the About url | |
Get ("About", About); | |
// Things like this also work: | |
// Post ("Foo", FooHandler); | |
// Route will send all methods to a handler (or another Module) | |
// Route ("Downloads", DownloadsHandler); | |
// Handlers can be functions or another module | |
// Route ("Admin", new AdminModule ()); | |
} | |
public static void About (MangoContext ctx) | |
{ | |
RenderTemplate (ctx, "about.html", new TemplateData () { | |
{ "message", "Hey, I am the about page." } | |
}); | |
} | |
// | |
// Handlers can be registered with attributes too | |
// | |
[Get ("$")] | |
public static void Home (MangoContext ctx) | |
{ | |
RenderTemplate (ctx, "home.html", new TemplateData () { | |
{ "message", "Welcome to the Mango-Project." } | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment