Switch ES2015 example to use middleware inlined into Startup.cs instead of MVC controller/action

This commit is contained in:
SteveSandersonMS
2015-11-02 21:02:47 -08:00
parent 0c59f670b2
commit e410affbd8
3 changed files with 21 additions and 35 deletions

View File

@@ -1,23 +0,0 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.NodeServices;
namespace ES2015Example.Controllers
{
public class ScriptController : Controller
{
private INodeServices nodeServices;
public ScriptController(INodeServices nodeServices) {
this.nodeServices = nodeServices;
}
public async Task<ContentResult> Transpile(string filename)
{
// TODO: Don't hard-code wwwroot; use proper path conversions
var fileContents = System.IO.File.ReadAllText("wwwroot/" + filename);
var transpiledResult = await this.nodeServices.Invoke("transpilation.js", fileContents, Request.Path.Value);
return Content(transpiledResult, "application/javascript");
}
}
}