|
|
@@ -1,6 +1,7 @@
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
|
|
+using System.Diagnostics.CodeAnalysis;
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Routing.Constraints;
|
|
|
@@ -21,7 +22,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="handler">The <see cref="RequestDelegate"/> route handler.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapRoute(this IRouteBuilder builder, string template, RequestDelegate handler)
|
|
|
+ public static IRouteBuilder MapRoute(this IRouteBuilder builder, [StringSyntax("Route")] string template, RequestDelegate handler)
|
|
|
{
|
|
|
var route = new Route(
|
|
|
new RouteHandler(handler),
|
|
|
@@ -43,7 +44,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="action">The action to apply to the <see cref="IApplicationBuilder"/>.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapMiddlewareRoute(this IRouteBuilder builder, string template, Action<IApplicationBuilder> action)
|
|
|
+ public static IRouteBuilder MapMiddlewareRoute(this IRouteBuilder builder, [StringSyntax("Route")] string template, Action<IApplicationBuilder> action)
|
|
|
{
|
|
|
var nested = builder.ApplicationBuilder.New();
|
|
|
action(nested);
|
|
|
@@ -58,7 +59,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="handler">The <see cref="RequestDelegate"/> route handler.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapDelete(this IRouteBuilder builder, string template, RequestDelegate handler)
|
|
|
+ public static IRouteBuilder MapDelete(this IRouteBuilder builder, [StringSyntax("Route")] string template, RequestDelegate handler)
|
|
|
{
|
|
|
return builder.MapVerb("DELETE", template, handler);
|
|
|
}
|
|
|
@@ -71,7 +72,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="action">The action to apply to the <see cref="IApplicationBuilder"/>.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapMiddlewareDelete(this IRouteBuilder builder, string template, Action<IApplicationBuilder> action)
|
|
|
+ public static IRouteBuilder MapMiddlewareDelete(this IRouteBuilder builder, [StringSyntax("Route")] string template, Action<IApplicationBuilder> action)
|
|
|
{
|
|
|
return builder.MapMiddlewareVerb("DELETE", template, action);
|
|
|
}
|
|
|
@@ -86,7 +87,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
public static IRouteBuilder MapDelete(
|
|
|
this IRouteBuilder builder,
|
|
|
- string template,
|
|
|
+ [StringSyntax("Route")] string template,
|
|
|
Func<HttpRequest, HttpResponse, RouteData, Task> handler)
|
|
|
{
|
|
|
return builder.MapVerb("DELETE", template, handler);
|
|
|
@@ -100,7 +101,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="handler">The <see cref="RequestDelegate"/> route handler.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapGet(this IRouteBuilder builder, string template, RequestDelegate handler)
|
|
|
+ public static IRouteBuilder MapGet(this IRouteBuilder builder, [StringSyntax("Route")] string template, RequestDelegate handler)
|
|
|
{
|
|
|
return builder.MapVerb(HttpMethods.Get, template, handler);
|
|
|
}
|
|
|
@@ -113,7 +114,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="action">The action to apply to the <see cref="IApplicationBuilder"/>.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapMiddlewareGet(this IRouteBuilder builder, string template, Action<IApplicationBuilder> action)
|
|
|
+ public static IRouteBuilder MapMiddlewareGet(this IRouteBuilder builder, [StringSyntax("Route")] string template, Action<IApplicationBuilder> action)
|
|
|
{
|
|
|
return builder.MapMiddlewareVerb(HttpMethods.Get, template, action);
|
|
|
}
|
|
|
@@ -128,7 +129,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
public static IRouteBuilder MapGet(
|
|
|
this IRouteBuilder builder,
|
|
|
- string template,
|
|
|
+ [StringSyntax("Route")] string template,
|
|
|
Func<HttpRequest, HttpResponse, RouteData, Task> handler)
|
|
|
{
|
|
|
return builder.MapVerb(HttpMethods.Get, template, handler);
|
|
|
@@ -142,7 +143,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="handler">The <see cref="RequestDelegate"/> route handler.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapPost(this IRouteBuilder builder, string template, RequestDelegate handler)
|
|
|
+ public static IRouteBuilder MapPost(this IRouteBuilder builder, [StringSyntax("Route")] string template, RequestDelegate handler)
|
|
|
{
|
|
|
return builder.MapVerb(HttpMethods.Post, template, handler);
|
|
|
}
|
|
|
@@ -155,7 +156,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="action">The action to apply to the <see cref="IApplicationBuilder"/>.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapMiddlewarePost(this IRouteBuilder builder, string template, Action<IApplicationBuilder> action)
|
|
|
+ public static IRouteBuilder MapMiddlewarePost(this IRouteBuilder builder, [StringSyntax("Route")] string template, Action<IApplicationBuilder> action)
|
|
|
{
|
|
|
return builder.MapMiddlewareVerb(HttpMethods.Post, template, action);
|
|
|
}
|
|
|
@@ -170,7 +171,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
public static IRouteBuilder MapPost(
|
|
|
this IRouteBuilder builder,
|
|
|
- string template,
|
|
|
+ [StringSyntax("Route")] string template,
|
|
|
Func<HttpRequest, HttpResponse, RouteData, Task> handler)
|
|
|
{
|
|
|
return builder.MapVerb(HttpMethods.Post, template, handler);
|
|
|
@@ -184,7 +185,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="handler">The <see cref="RequestDelegate"/> route handler.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapPut(this IRouteBuilder builder, string template, RequestDelegate handler)
|
|
|
+ public static IRouteBuilder MapPut(this IRouteBuilder builder, [StringSyntax("Route")] string template, RequestDelegate handler)
|
|
|
{
|
|
|
return builder.MapVerb(HttpMethods.Put, template, handler);
|
|
|
}
|
|
|
@@ -197,7 +198,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <param name="template">The route template.</param>
|
|
|
/// <param name="action">The action to apply to the <see cref="IApplicationBuilder"/>.</param>
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
- public static IRouteBuilder MapMiddlewarePut(this IRouteBuilder builder, string template, Action<IApplicationBuilder> action)
|
|
|
+ public static IRouteBuilder MapMiddlewarePut(this IRouteBuilder builder, [StringSyntax("Route")] string template, Action<IApplicationBuilder> action)
|
|
|
{
|
|
|
return builder.MapMiddlewareVerb(HttpMethods.Put, template, action);
|
|
|
}
|
|
|
@@ -212,7 +213,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
/// <returns>A reference to the <paramref name="builder"/> after this operation has completed.</returns>
|
|
|
public static IRouteBuilder MapPut(
|
|
|
this IRouteBuilder builder,
|
|
|
- string template,
|
|
|
+ [StringSyntax("Route")] string template,
|
|
|
Func<HttpRequest, HttpResponse, RouteData, Task> handler)
|
|
|
{
|
|
|
return builder.MapVerb(HttpMethods.Put, template, handler);
|
|
|
@@ -230,7 +231,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
public static IRouteBuilder MapVerb(
|
|
|
this IRouteBuilder builder,
|
|
|
string verb,
|
|
|
- string template,
|
|
|
+ [StringSyntax("Route")] string template,
|
|
|
Func<HttpRequest, HttpResponse, RouteData, Task> handler)
|
|
|
{
|
|
|
RequestDelegate requestDelegate = (httpContext) =>
|
|
|
@@ -253,7 +254,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
public static IRouteBuilder MapVerb(
|
|
|
this IRouteBuilder builder,
|
|
|
string verb,
|
|
|
- string template,
|
|
|
+ [StringSyntax("Route")] string template,
|
|
|
RequestDelegate handler)
|
|
|
{
|
|
|
var constraints = new RouteValueDictionary
|
|
|
@@ -285,7 +286,7 @@ public static class RequestDelegateRouteBuilderExtensions
|
|
|
public static IRouteBuilder MapMiddlewareVerb(
|
|
|
this IRouteBuilder builder,
|
|
|
string verb,
|
|
|
- string template,
|
|
|
+ [StringSyntax("Route")] string template,
|
|
|
Action<IApplicationBuilder> action)
|
|
|
{
|
|
|
var nested = builder.ApplicationBuilder.New();
|