-
-
Save prabirshrestha/3688680 to your computer and use it in GitHub Desktop.
sample app demon using owin extension methods and fluent api
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
| var app = new List<Func<AppFunc, AppFunc>>(); | |
| app | |
| .Use(Favicon.Middleware()) | |
| .Use(IeEdgeChromeFrameHeader.Middleware()) | |
| .Use(RemovePoweredBy.Middleware()) | |
| .Use(CrossDomainRules.Middleware()) | |
| .Use(QueryParser.Middleware()) | |
| .Use(JsonBodyParser.Middleware()) | |
| .Use(UrlEncoded.Middleware()) | |
| .Use(MethodOverride.Middleware()) | |
| .UriTemplateRoute() | |
| .Configure | |
| ["/owin"] | |
| .Cache(c => c.MaxAge = 86400) | |
| .Cache(c => c.Public = true) | |
| ["/environment"] | |
| .Application(new EnvironmentApplication()) | |
| .End | |
| ["/uri"] | |
| .Application(new EnvironmentUriApplication()) | |
| .End | |
| ["/headers"] | |
| .Application(new EnvironmentRequestHeaders()) | |
| .End | |
| .End | |
| ["/sample"] | |
| .Get(new ShowFormSample()) | |
| .Post(new HandleFormSubmit()) | |
| ["/scripts"] | |
| .Cache(c => c.MaxAge = 86400) | |
| .Cache(c => c.Public = true) | |
| .Files("scripts") | |
| .End | |
| ["/styles"] | |
| .Cache(c => c.MaxAge = 86400) | |
| .Cache(c => c.Public = true) | |
| .Files("scripts") | |
| .End | |
| return app.ToOwinApp() |
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
| app | |
| .RegexRouter() | |
| ["hello"] | |
| .Use(CrossDomainRules.Middleware()) | |
| .Use(RemovePoweredBy.Middleware()) | |
| .Get | |
| .Use(next => | |
| async env => | |
| { | |
| await env | |
| .GetOwinResponseBody() | |
| .WriteStringAsync("Hello world - GET"); | |
| }) | |
| .End | |
| .All | |
| .Use(MethodOverride.Middleware()) | |
| .Use(next => | |
| async env => | |
| { | |
| await env | |
| .GetOwinResponseBody() | |
| .WriteStringAsync("hello world"); | |
| }) | |
| .End | |
| .End | |
| ["*"] | |
| .All | |
| .Use(next => | |
| async env => { | |
| await env | |
| .SetOwinResponseStatusCode(404) | |
| .GetOwinResponseBody() | |
| .WriteStringAsync("not found"); | |
| }) | |
| .End | |
| .End | |
| .Unwrap(); // or .End (if using .End you will have to assign it to some variable due to c# limitations) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment