Created
September 13, 2012 00:22
-
-
Save ahall/3710955 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
public class BlogPost | |
{ | |
public string Name { get; set; } | |
public int Age { get; set; } | |
} | |
public class BlogModule : SinatraModule // Or whatever name we come up with | |
{ | |
// This maps to /blogposts/edit/{id} | |
[Route("/edit/{id}", ApplyTo.Get | ApplyTo.Post)] | |
public object Edit(int id, Post post) | |
{ | |
} | |
[Route("/blah/{name}/{type}", ApplyTo.Get | ApplyTo.Post)] | |
public void Blah(string name, string type) | |
{ | |
var post = this.Deserialize<BlogPost>(); | |
// Do something with blogpost | |
} | |
} | |
public class AppHost : AppHostHttpListenerBase | |
{ | |
public override void Configure(Funq.Container container) | |
{ | |
Routes.Add(MyService); // Register all regular services which take priority. | |
// Register the module under prefix /blogposts | |
RegisterSinatraModule(typeof(BlogModule, "/blogposts")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
public class BlogPost
{
public string Name { get; set; }
public int Age { get; set; }
}