forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpControllerRouteHandler.cs
More file actions
56 lines (50 loc) · 2.06 KB
/
HttpControllerRouteHandler.cs
File metadata and controls
56 lines (50 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Web.Routing;
namespace System.Web.Http.WebHost
{
/// <summary>
/// A <see cref="IRouteHandler"/> that returns instances of <see cref="HttpControllerHandler"/> that
/// can pass requests to a given <see cref="HttpServer"/> instance.
/// </summary>
public class HttpControllerRouteHandler : IRouteHandler
{
private static readonly Lazy<HttpControllerRouteHandler> _instance =
new Lazy<HttpControllerRouteHandler>(() => new HttpControllerRouteHandler(), isThreadSafe: true);
/// <summary>
/// Initializes a new instance of the <see cref="HttpControllerRouteHandler"/> class.
/// </summary>
protected HttpControllerRouteHandler()
{
}
/// <summary>
/// Gets the singleton <see cref="HttpControllerRouteHandler"/> instance.
/// </summary>
public static HttpControllerRouteHandler Instance
{
get { return _instance.Value; }
}
/// <summary>
/// Provides the object that processes the request.
/// </summary>
/// <param name="requestContext">An object that encapsulates information about the request.</param>
/// <returns>
/// An object that processes the request.
/// </returns>
IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext)
{
return GetHttpHandler(requestContext);
}
/// <summary>
/// Provides the object that processes the request.
/// </summary>
/// <param name="requestContext">An object that encapsulates information about the request.</param>
/// <returns>
/// An object that processes the request.
/// </returns>
protected virtual IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return new HttpControllerHandler(requestContext.RouteData);
}
}
}