Last active
December 18, 2015 13:59
-
-
Save bhameyie/5794108 to your computer and use it in GitHub Desktop.
A simple Secured Module
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 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