Skip to content

Instantly share code, notes, and snippets.

@bhameyie
Last active December 18, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhameyie/5794108 to your computer and use it in GitHub Desktop.
Save bhameyie/5794108 to your computer and use it in GitHub Desktop.
A simple Secured Module
public class BloggerModule : SecureModule
{
private readonly IBlogServiceClient m_blogService;
public BloggerModule(IBlogServiceClient blogService)
: base("/blog")
{
m_blogService = blogService;
Get["/{Id}"] = parameters =>
{
var blogPost = m_blogService.GetBlogPost((long)parameters.Id,
(Context.CurrentUser as SessionUser).ApiToken);
return Negotiate.WithView("BlogPostDetail") //Use the Negotiatior to prepare my response
.WithModel(blogPost)
.WithStatusCode(HttpStatusCode.OK);
};
Get["/create"] = parameters => Negotiate.WithView("CreateBlogPost").WithStatusCode(HttpStatusCode.OK);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment