Skip to content

Commit 25c1ef3

Browse files
committed
Adding a Home controller to serve requests to the site root with a 204
1 parent 183810c commit 25c1ef3

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/WebJobs.Script.WebHost/App_Start/WebApiConfig.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public static void Register(HttpConfiguration config)
2424
// Web API routes
2525
config.MapHttpAttributeRoutes();
2626

27+
config.Routes.MapHttpRoute(
28+
name: "Home",
29+
routeTemplate: "",
30+
defaults: new { controller = "Home" }
31+
);
32+
2733
config.Routes.MapHttpRoute(
2834
name: "Functions",
2935
routeTemplate: "{*uri}",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using System.Net;
5+
using System.Net.Http;
6+
using System.Web.Http;
7+
8+
namespace WebJobs.Script.WebHost.Controllers
9+
{
10+
public class HomeController : ApiController
11+
{
12+
public HttpResponseMessage Get()
13+
{
14+
// TODO: Eventually we'll want to consider returning a content
15+
// page
16+
return new HttpResponseMessage(HttpStatusCode.NoContent);
17+
}
18+
}
19+
}

src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
<Compile Include="App_Start\WebApiConfig.cs" />
229229
<Compile Include="Controllers\AdminController.cs" />
230230
<Compile Include="Controllers\FunctionsController.cs" />
231+
<Compile Include="Controllers\HomeController.cs" />
231232
<Compile Include="Filters\AuthorizationLevelAttribute.cs" />
232233
<Compile Include="FunctionSecrets.cs" />
233234
<Compile Include="Global.asax.cs">

src/WebJobs.Script/Host/ScriptHostManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public ScriptHost Instance
5757
_config.HostConfig = new JobHostConfiguration();
5858
ScriptHost newInstance = ScriptHost.Create(_config);
5959

60+
// TODO: consider using StartAsync here to speed up
61+
// restarts.
6062
newInstance.Start();
6163
lock (_liveInstances)
6264
{

0 commit comments

Comments
 (0)