-
Notifications
You must be signed in to change notification settings - Fork 926
React.Owin #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React.Owin #69
Conversation
public override string MapPath(string relativePath) | ||
{ | ||
if (relativePath.StartsWith("~")) | ||
return Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), relativePath.Replace("~", string.Empty)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be unit tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assembly.GetEntryAssembly()
will be null under nunit runner. I can change design to get around this somehow, however I'm not sure if this is good idea for something that simple
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused references
Thanks for this! I just wrote a bunch of comments. Please ensure you're using the same assembly settings as the rest of ReactJS.NET. Notably, "warnings as errors" should be enabled for release builds. Use tabs for indentation in C# files. Also please don't add jQuery to any examples. Ideally I'd like if you reused the same sample code from Please run the |
Thanks for all your effort to do this review! I hope I covered all your comments. I used the sample code from |
/// <param name="container">Container to register components in</param> | ||
public void Register(TinyIoCContainer container) | ||
{ | ||
container.Register<IFileSystem, EntryAssemblyFileSystem>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the indentation to use tabs everywhere - This file is a mix of spaces and tabs.
Thanks for working on this! I really appreciate it :) |
I've merged your changes! It would be awesome to get some documentation on this feature (just a Markdown file in site/jekyll/guides) but that's totally optional and I can write something if you don't get around to it. Just a basic explanation of what's supported and how to use it :) Again, thanks! :D |
Is there a nuget package with React.Owin? |
@ilyapalkin Good point! I just noticed there's no NuGet package for React.Owin. Hahaha. Just created a config for it, it will be available with the next ReactJS.NET release (which should be soon), or you could use the version off the build server once it picks up the change. |
NuGet package is up now: https://www.nuget.org/packages/React.Owin/ |
React.Owin
I've created Owin middleware for serving transformed JSX files. It's built on top core React library and Owin / Katana StaticFileMiddleware.
I know it's a big pull request, but since I already written it to use in my project, I thought I could share the code.
Why Owin?
Owin compatible code begins to take lot of attention in .NET. WebAPI 2 can be treated just as Owin middleware, and MVC 6 will be completely based on Owin.
I'm developing a web app in react.js, hosted on Owin-based service. To take advantage of server-side JSX transformation, I created middleware that uses React.Net to serve JSX files compiled to JavaScript.
Structure
I tried to retain the structure and standards of existing React.NET code: every file has a Facebook boilerplate, project libraries have links to shared assembly info files and there's included sample project that uses Microsoft.Owin.SelfHost.
The most important classes are:
JsxFileMiddleware
which is wrapper around OwinStaticFileMiddleware
, but uses it's own FileSystem.JsxFileSystem
- a decorator class aroundIFileSystem
- that transforms the JSX file when requested.Tests
I didn't include any tests for the code - it's hard for me to come up with something. Cache implementation is rather straightforward usage of
System.Runtime.Caching
, middleware itself configures built-inStaticFileMiddleware
, andJsxFileSystem
(which handles the transformation) is almost entirely based onIJsxTransformer
.