public void Parse_OptionalParameter() { // Arrange var template = "{p?}"; var expected = new RouteTemplate(template, new List <TemplateSegment>()); expected.Segments.Add(new TemplateSegment()); expected.Segments[0].Parts.Add( TemplatePart.CreateParameter("p", false, true, defaultValue: null, inlineConstraints: null)); expected.Parameters.Add(expected.Segments[0].Parts[0]); // Act var actual = TemplateParser.Parse(template); // Assert Assert.Equal <RouteTemplate>(expected, actual, new TemplateEqualityComparer()); }
public static decimal Compute(RouteTemplate template) { // Each precedence digit corresponds to one decimal place. For example, 3 segments with precedences 2, 1, // and 4 results in a combined precedence of 2.14 (decimal). var precedence = 0m; for (var i = 0; i < template.Segments.Count; i++) { var segment = template.Segments[i]; var digit = ComputeDigit(segment); Contract.Assert(digit >= 0 && digit < 10); precedence += Decimal.Divide(digit, (decimal)Math.Pow(10, i)); } return(precedence); }
public void Parse_MultipleLiterals() { // Arrange var template = "cool/awesome/super"; var expected = new RouteTemplate(template, new List <TemplateSegment>()); expected.Segments.Add(new TemplateSegment()); expected.Segments[0].Parts.Add(TemplatePart.CreateLiteral("cool")); expected.Segments.Add(new TemplateSegment()); expected.Segments[1].Parts.Add(TemplatePart.CreateLiteral("awesome")); expected.Segments.Add(new TemplateSegment()); expected.Segments[2].Parts.Add(TemplatePart.CreateLiteral("super")); // Act var actual = TemplateParser.Parse(template); // Assert Assert.Equal <RouteTemplate>(expected, actual, new TemplateEqualityComparer()); }
private static string GenerateRequestUrl(RouteTemplate template) { if (template.Segments.Count == 0) { return("/"); } var url = new StringBuilder(); for (var i = 0; i < template.Segments.Count; i++) { // We don't yet handle complex segments var part = template.Segments[i].Parts[0]; url.Append('/'); url.Append(part.IsLiteral ? part.Text : GenerateParameterValue(part)); } return(url.ToString()); }
public void returns_matches_with_provided_keys() { var pattern = new Regex(@"(?i)^/api/([^/]{1,20})/(\d+)$"); var patterKeys = new List <string>() { "resource", "id" }; var sample = "/api/users/1234"; var template = new RouteTemplate(pattern, patterKeys); template.Matches(sample).ShouldBeTrue(); var matches = template.ParseEndpoint(sample); matches.Count.ShouldBe(2); matches.ContainsKey("resource").ShouldBeTrue(); matches.ContainsKey("id").ShouldBeTrue(); matches["resource"].ShouldBe("users"); matches["id"].ShouldBe("1234"); }
public void Configure(IApplicationBuilder app) { //We are building a url template from scratch, segment by segemtn, oldskool var segment = new TemplateSegment(); segment.Parts.Add(TemplatePart.CreateLiteral("page")); segment.Parts.Add(TemplatePart.CreateParameter("title", isCatchAll: true, isOptional: true, defaultValue: null, inlineConstraints: new InlineConstraint[] {}) ); var segments = new TemplateSegment [] { segment }; var template = new RouteTemplate("page", segments.ToList()); var templateMatcher = new TemplateMatcher(template, new RouteValueDictionary()); app.Use(async(context, next) => { await context.Response.WriteAsync("We are using one segment with two parts, one Literal Template Part ('page') and the other with Parameter Template Part ('title')."); await context.Response.WriteAsync("It is the equivalent of /page{title}"); await context.Response.WriteAsync("\n\n"); await next.Invoke(); }); app.Use(async(context, next) => { var path1 = "/pagemy-amazing-travel"; var routeData = new RouteValueDictionary();//This dictionary will be populated by the parameter template part (in this case "title") var isMatch1 = templateMatcher.TryMatch(path1, routeData); await context.Response.WriteAsync($"{path1} is match? {isMatch1} => route data value for 'title' is {routeData["title"]} \n"); await next.Invoke(); }); app.Use(async(context, next) => { var path1 = "/pagenothing-compares-2-u"; var routeData = new RouteValueDictionary();//This dictionary will be populated by the parameter template part (in this case "title") var isMatch1 = templateMatcher.TryMatch(path1, routeData); await context.Response.WriteAsync($"{path1} is match? {isMatch1} => route data value for 'title' is {routeData["title"]} \n"); }); }
public TemplateMatcher( RouteTemplate template, RouteValueDictionary defaults) { if (template == null) { throw new ArgumentNullException(nameof(template)); } Template = template; Defaults = defaults ?? new RouteValueDictionary(); // Perf: cache the default value for each parameter (other than complex segments). _hasDefaultValue = new bool[Template.Segments.Count]; _defaultValues = new object[Template.Segments.Count]; for (var i = 0; i < Template.Segments.Count; i++) { var segment = Template.Segments[i]; if (!segment.IsSimple) { continue; } var part = segment.Parts[0]; if (!part.IsParameter) { continue; } if (Defaults.TryGetValue(part.Name !, out var value)) { _hasDefaultValue[i] = true; _defaultValues[i] = value; } } var routePattern = Template.ToRoutePattern(); _routePatternMatcher = new RoutePatternMatcher(routePattern, Defaults); }
private bool UseDefaultValuePlusRemainingSegementsOptional( int segmentIndex, ActionDescriptor action, MvcEndpointInfo endpointInfo, RouteTemplate template) { // Check whether the remaining segments are all optional and one or more of them is // for area/controller/action and has a default value var usedDefaultValue = false; for (var i = segmentIndex; i < template.Segments.Count; i++) { var segment = template.Segments[i]; for (var j = 0; j < segment.Parts.Count; j++) { var part = segment.Parts[j]; if (part.IsOptional || part.IsOptionalSeperator || part.IsCatchAll) { continue; } if (part.IsParameter) { if (IsMvcParameter(part.Name)) { if (endpointInfo.MergedDefaults[part.Name] is string defaultValue && action.RouteValues.TryGetValue(part.Name, out var routeValue) && string.Equals(defaultValue, routeValue, StringComparison.OrdinalIgnoreCase)) { usedDefaultValue = true; continue; } } } // Stop because there is a non-optional/non-defaulted trailing value return(false); } } return(usedDefaultValue); }
public RouteTemplate GenerateRouteTemplateObject(SqlDataReader sqlDataReader) { objRouteTemplate = new RouteTemplate(); objRouteTemplate.RouteTemplateID = Convert.ToInt32(sqlDataReader["RouteTemplateID"]); objRouteTemplate.Name = sqlDataReader["Name"].ToString(); objRouteTemplate.Description = sqlDataReader["Description"].ToString(); objRouteTemplate.Blocked = Convert.ToByte(sqlDataReader["Blocked"]); objRouteTemplate.RowStatus = (short)sqlDataReader["RowStatus"]; objRouteTemplate.CreatedBy = sqlDataReader["CreatedBy"].ToString(); if (sqlDataReader["CreatedTime"] != null && sqlDataReader["CreatedTime"].ToString() != "") { objRouteTemplate.CreatedTime = Convert.ToDateTime(sqlDataReader["CreatedTime"]); } objRouteTemplate.LastModifiedBy = sqlDataReader["LastModifiedBy"].ToString(); if (sqlDataReader["LastModifiedTime"] != null && sqlDataReader["LastModifiedTime"].ToString() != "") { objRouteTemplate.LastModifiedTime = Convert.ToDateTime(sqlDataReader["LastModifiedTime"]); } return(objRouteTemplate); }
public void Configure(IApplicationBuilder app) { var apiSegment = new TemplateSegment(); apiSegment.Parts.Add(TemplatePart.CreateLiteral("api")); var serviceNameSegment = new TemplateSegment(); serviceNameSegment.Parts.Add( TemplatePart.CreateParameter("serviceName", isCatchAll: false, isOptional: true, defaultValue: null, inlineConstraints: new InlineConstraint[] { }) ); var segments = new TemplateSegment[] { apiSegment, serviceNameSegment }; var routeTemplate = new RouteTemplate("default", segments.ToList()); var templateMatcher = new TemplateMatcher(routeTemplate, new RouteValueDictionary()); app.Use(async(context, next) => { context.Response.Headers.Add("Content-type", "text/html"); var requestPath = context.Request.Path; var routeData = new RouteValueDictionary(); var isMatch = templateMatcher.TryMatch(requestPath, routeData); await context.Response.WriteAsync($"Request Path is <i>{requestPath}</i><br/>Match state is <b>{isMatch}</b><br/>Requested service name is {routeData["serviceName"]}"); await next.Invoke(); }); app.Run(async context => { await context.Response.WriteAsync(""); }); }
public void Parse_ComplexSegment_PL() { // Arrange var template = "{p1}-cool"; var expected = new RouteTemplate(template, new List <TemplateSegment>()); expected.Segments.Add(new TemplateSegment()); expected.Segments[0].Parts.Add(TemplatePart.CreateParameter("p1", false, false, defaultValue: null, inlineConstraints: null)); expected.Parameters.Add(expected.Segments[0].Parts[0]); expected.Segments[0].Parts.Add(TemplatePart.CreateLiteral("cool-")); // Act var actual = TemplateParser.Parse(template); // Assert Assert.Equal <RouteTemplate>(expected, actual, new TemplateEqualityComparer()); }
public void Parse_ComplexSegment_OptionalParameterFollowingPeriod_ThreeParameters() { // Arrange var template = "{p1}.{p2}.{p3?}"; var expected = new RouteTemplate(template, new List <TemplateSegment>()); expected.Segments.Add(new TemplateSegment()); expected.Segments[0].Parts.Add(TemplatePart.CreateParameter("p1", false, false, defaultValue: null, inlineConstraints: null)); expected.Segments[0].Parts.Add(TemplatePart.CreateLiteral(".")); expected.Segments[0].Parts.Add(TemplatePart.CreateParameter("p2", false, false, defaultValue: null, inlineConstraints: null)); expected.Segments[0].Parts.Add(TemplatePart.CreateLiteral(".")); expected.Segments[0].Parts.Add(TemplatePart.CreateParameter("p3", false, true, defaultValue: null, inlineConstraints: null)); expected.Parameters.Add(expected.Segments[0].Parts[0]); expected.Parameters.Add(expected.Segments[0].Parts[2]); expected.Parameters.Add(expected.Segments[0].Parts[4]); // Act var actual = TemplateParser.Parse(template); // Assert Assert.Equal <RouteTemplate>(expected, actual, new TemplateEqualityComparer()); }
// Merge inline and non inline defaults into one private RouteValueDictionary GetDefaults(RouteTemplate parsedTemplate, RouteValueDictionary nonInlineDefaults) { var result = nonInlineDefaults == null ? new RouteValueDictionary() : new RouteValueDictionary(nonInlineDefaults); foreach (var parameter in parsedTemplate.Parameters) { if (parameter.DefaultValue != null) { if (result.ContainsKey(parameter.Name)) { throw new InvalidOperationException( Resources.FormatTemplateRoute_CannotHaveDefaultValueSpecifiedInlineAndExplicitly( parameter.Name)); } else { result.Add(parameter.Name, parameter.DefaultValue); } } } return(result); }
/// <summary> /// Checks whether the endpoint is matched the relative uri specified int the request info. /// </summary> /// <param name="routeEndpoint">The route endpoint.</param> /// <param name="requestInfo">The request information.</param> /// <param name="routeValueDictionary">The route value dictionary.</param> /// <returns> /// Whether the endpoint matches the request info relative uri. /// </returns> private static EndpointMatchResult EndpointMatches(RouteEndpoint routeEndpoint, RequestInfo requestInfo, out RouteValueDictionary routeValueDictionary) { if (!_templateMatcherCache.TryGetValue(routeEndpoint.RoutePattern.RawText, out TemplateMatcher templateMatcher)) { RouteTemplate template = TemplateParser.Parse(routeEndpoint.RoutePattern.RawText); templateMatcher = new TemplateMatcher(template, GetDefaultRouteValues(template)); _templateMatcherCache.TryAdd(routeEndpoint.RoutePattern.RawText, templateMatcher); } routeValueDictionary = new RouteValueDictionary(); if (templateMatcher.TryMatch(new PathString(requestInfo.RelativeUri), routeValueDictionary)) { // Check if the HTTP method matches string requestHttpMethod = requestInfo.Method.ToLower(); HttpMethodMetadata httpMethodMetadata = routeEndpoint.Metadata.GetMetadata <HttpMethodMetadata>(); if (httpMethodMetadata == null && requestHttpMethod != HttpMethod.Get.ToString().ToLower()) { // Assume get if no metadata is found return(EndpointMatchResult.NoMatch); } if (!httpMethodMetadata.HttpMethods.Any(httpMethod => httpMethod.ToLower() == requestHttpMethod)) { // Http method is not matching return(EndpointMatchResult.NoMatch); } // Check if this endpoint is ignored, allowed takes precedence IgnoreForBatchRequestAttribute ignoreAttribute = routeEndpoint.Metadata.GetMetadata <IgnoreForBatchRequestAttribute>(); AllowForBatchRequestAttribute allowAttribute = routeEndpoint.Metadata.GetMetadata <AllowForBatchRequestAttribute>(); if (ignoreAttribute != null && allowAttribute == null) { return(EndpointMatchResult.Ignored); } return(EndpointMatchResult.Match); } return(EndpointMatchResult.NoMatch); }
public void Parse_MultipleParameters() { // Arrange var template = "{p1}/{p2}/{*p3}"; var expected = new RouteTemplate(new List <TemplateSegment>()); expected.Segments.Add(new TemplateSegment()); expected.Segments[0].Parts.Add(TemplatePart.CreateParameter("p1", false, false, defaultValue: null, inlineConstraint: null)); expected.Parameters.Add(expected.Segments[0].Parts[0]); expected.Segments.Add(new TemplateSegment()); expected.Segments[1].Parts.Add(TemplatePart.CreateParameter("p2", false, false, defaultValue: null, inlineConstraint: null)); expected.Parameters.Add(expected.Segments[1].Parts[0]); expected.Segments.Add(new TemplateSegment()); expected.Segments[2].Parts.Add(TemplatePart.CreateParameter("p3", true, false, defaultValue: null, inlineConstraint: null)); expected.Parameters.Add(expected.Segments[2].Parts[0]); // Act var actual = TemplateParser.Parse(template, _inlineConstraintResolver); // Assert Assert.Equal <RouteTemplate>(expected, actual, new TemplateEqualityComparer()); }
/// <summary> /// Processes the constraints for the specified template. /// </summary> /// <param name="rawTemplate">Raw template string</param> /// <param name="parsedTemplate">Parsed template</param> /// <returns>The constraints for this route</returns> private IDictionary <string, object> GetConstraints(string rawTemplate, RouteTemplate parsedTemplate) { var constraintBuilder = new RouteConstraintBuilder(_constraintResolver, rawTemplate); foreach (var parameter in parsedTemplate.Parameters) { if (parameter.InlineConstraints != null) { if (parameter.IsOptional) { constraintBuilder.SetOptional(parameter.Name); } foreach (var inlineConstraint in parameter.InlineConstraints) { constraintBuilder.AddResolvedConstraint(parameter.Name, inlineConstraint.Constraint); } } } var constraints = constraintBuilder.Build(); return(_constraintsProcessor.ProcessConstraints(constraints)); }
private string GetLink( RouteTemplate template, RouteValueDictionary defaults, RouteValueDictionary explicitValues, RouteValueDictionary ambientValues) { var templateBinder = new TemplateBinder( UrlEncoder.Default, _uriBuildingContextPool, template, defaults); var values = templateBinder.GetValues(ambientValues, explicitValues); if (values == null) { // We're missing one of the required values for this route. return(null); } //TODO: route constraint matching here return(templateBinder.BindValues(values.AcceptedValues)); }
private static RouteValueDictionary GetDefaults( RouteTemplate parsedTemplate, RouteValueDictionary defaults) { var result = defaults == null ? new RouteValueDictionary() : new RouteValueDictionary(defaults); foreach (var parameter in parsedTemplate.Parameters) { if (parameter.DefaultValue != null) { if (result.ContainsKey(parameter.Name)) { throw new InvalidOperationException( string.Format(CultureInfo.CurrentCulture, "The route parameter '{0}' has both an inline default value and an explicit default value specified. A route parameter cannot contain an inline default value when a default value is specified explicitly. Consider removing one of them.", parameter.Name)); } else { result.Add(parameter.Name, parameter.DefaultValue); } } } return(result); }
[InlineData(@"{p1:regex(([{{(])\w+)}", @"regex(([{(])\w+)")] // Not balanced { public void Parse_RegularExpressions(string template, string constraint) { // Arrange var expected = new RouteTemplate(template, new List <TemplateSegment>()); expected.Segments.Add(new TemplateSegment()); var c = new InlineConstraint(constraint); expected.Segments[0].Parts.Add( TemplatePart.CreateParameter("p1", false, false, defaultValue: null, inlineConstraints: new List <InlineConstraint> { c })); expected.Parameters.Add(expected.Segments[0].Parts[0]); // Act var actual = TemplateParser.Parse(template); // Assert Assert.Equal <RouteTemplate>(expected, actual, new TemplateEqualityComparer()); }
/// <summary> /// Processes the defaults for the specified action. /// </summary> /// <param name="action">MVC action</param> /// <param name="template">Route template for this action</param> /// <returns>Defaults for this action</returns> private IDictionary <string, object> GetDefaults(ControllerActionDescriptor action, RouteTemplate template) { var defaults = template.Parameters .Where(p => p.DefaultValue != null) .ToDictionary( p => p.Name.ToLowerInvariant(), p => p.DefaultValue, StringComparer.OrdinalIgnoreCase ); defaults.Add("controller", action.ControllerName); defaults.Add("action", action.ActionName); return(defaults); }
public SkillCallingRequestHandler(ITurnContext turnContext, Action <Activity> tokenRequestHandler = null, Action <Activity> handoffActivityHandler = null) { _turnContext = turnContext ?? throw new ArgumentNullException(nameof(turnContext)); _tokenRequestHandler = tokenRequestHandler; _handoffActivityHandler = handoffActivityHandler; var routes = new RouteTemplate[] { new RouteTemplate() { Method = "POST", Path = "/activities/{activityId}", Action = new RouteAction() { Action = async(request, routeData) => { var activity = await request.ReadBodyAsJson <Activity>().ConfigureAwait(false); if (activity != null) { if (activity.Type == ActivityTypes.Event && activity.Name == TokenEvents.TokenRequestEventName) { if (_tokenRequestHandler != null) { _tokenRequestHandler(activity); return(new ResourceResponse()); } else { throw new ArgumentNullException("TokenRequestHandler", "Skill is requesting for token but there's no handler on the calling side!"); } } else if (activity.Type == ActivityTypes.EndOfConversation) { if (_handoffActivityHandler != null) { _handoffActivityHandler(activity); return(new ResourceResponse()); } else { throw new ArgumentNullException("HandoffActivityHandler", "Skill is sending handoff activity but there's no handler on the calling side!"); } } else { var result = await _turnContext.SendActivityAsync(activity).ConfigureAwait(false); return(result); } } else { throw new Exception("Error deserializing activity response!"); } }, }, }, new RouteTemplate() { Method = "PUT", Path = "/activities/{activityId}", Action = new RouteAction() { Action = async(request, routeData) => { var activity = await request.ReadBodyAsJson <Activity>().ConfigureAwait(false); var result = _turnContext.UpdateActivityAsync(activity).ConfigureAwait(false); return(result); }, }, }, new RouteTemplate() { Method = "DELETE", Path = "/activities/{activityId}", Action = new RouteAction() { Action = async(request, routeData) => { var result = await _turnContext.DeleteActivityAsync(routeData.activityId); return(result); }, }, }, }; _router = new Router(routes); }
/// <summary> /// Adds a new outbound route to the <see cref="TreeRouter"/>. /// </summary> /// <param name="handler">The <see cref="IRouter"/> for handling the link generation.</param> /// <param name="routeTemplate">The <see cref="RouteTemplate"/> of the route.</param> /// <param name="requiredLinkValues">The <see cref="RouteValueDictionary"/> containing the route values.</param> /// <param name="routeName">The route name.</param> /// <param name="order">The route order.</param> /// <returns>The <see cref="OutboundRouteEntry"/>.</returns> public OutboundRouteEntry MapOutbound( IRouter handler, RouteTemplate routeTemplate, RouteValueDictionary requiredLinkValues, string routeName, int order) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } if (routeTemplate == null) { throw new ArgumentNullException(nameof(routeTemplate)); } if (requiredLinkValues == null) { throw new ArgumentNullException(nameof(requiredLinkValues)); } var entry = new OutboundRouteEntry() { Handler = handler, Order = order, Precedence = RoutePrecedence.ComputeOutbound(routeTemplate), RequiredLinkValues = requiredLinkValues, RouteName = routeName, RouteTemplate = routeTemplate, }; var constraintBuilder = new RouteConstraintBuilder(_constraintResolver, routeTemplate.TemplateText); foreach (var parameter in routeTemplate.Parameters) { if (parameter.InlineConstraints != null) { if (parameter.IsOptional) { constraintBuilder.SetOptional(parameter.Name); } foreach (var constraint in parameter.InlineConstraints) { constraintBuilder.AddResolvedConstraint(parameter.Name, constraint.Constraint); } } } entry.Constraints = constraintBuilder.Build(); entry.Defaults = new RouteValueDictionary(); foreach (var parameter in entry.RouteTemplate.Parameters) { if (parameter.DefaultValue != null) { entry.Defaults.Add(parameter.Name, parameter.DefaultValue); } } OutboundEntries.Add(entry); return(entry); }
/// <summary> /// For Service Interface only /// </summary> public ApiSpecAttribute(Type svcInterfaceType, RouteTemplate routeTemplate) //: this(new string[] { "GET" }, template) { HttpMethods = new string[] { }; SetupRouteTemplate(svcInterfaceType, routeTemplate); }
public bool TryUrlMatching(string method, PathString url, RouteValueDictionary routeValues, out RouteTemplate routeTemplate) { foreach (var template in _templates) { if (template.HttpMethod == null || template.HttpMethod.Equals(method, StringComparison.OrdinalIgnoreCase)) { if (template.Matcher.Template.TemplateText == AllUrlWildcard || template.Matcher.TryMatch(url, routeValues)) { routeTemplate = template.Matcher.Template; return(true); } } } routeTemplate = null; return(false); }
/// <summary> /// Replace a variable in the <c>RouteTemplate</c> with a specified value. /// </summary> /// <param name="variableName">The variable name to replace.</param> /// <param name="variableValue">The value to replace with.</param> /// <param name="workingRoute">An 'in progress' route that may contain values that have already been replaced.</param> /// <returns>A <c>workingRoute</c></returns> public string SetVariable(string variableName, string variableValue, string workingRoute = null) { if (!variableName.StartsWith(VariableStartChar.ToString()) && !variableName.EndsWith(VariableEndChar.ToString())) { variableName = $"{VariableStartChar}{variableName}{VariableEndChar}"; } return(!string.IsNullOrEmpty(workingRoute) ? workingRoute.Replace(variableName, variableValue) : RouteTemplate.Replace(variableName, variableValue)); }
public void Configure(IApplicationBuilder app) { //We are building a url template from scratch, segment by segment, oldskool var segment = new TemplateSegment(); segment.Parts.Add( TemplatePart.CreateLiteral("hello") ); var segment2 = new TemplateSegment(); segment2.Parts.Add( TemplatePart.CreateLiteral("world") ); var segments = new TemplateSegment [] { segment, segment2 }; var template = new RouteTemplate("hello", segments.ToList()); var templateMatcher = new TemplateMatcher(template, new RouteValueDictionary()); app.Use(async(context, next) => { await context.Response.WriteAsync("We are building routing from scratch using a template segment consisted of two parts: 'hello' and 'world'.\n\n"); await next.Invoke(); }); app.Use(async(context, next) => { var path1 = "hello/world"; try { var isMatch1 = templateMatcher.TryMatch(path1, new RouteValueDictionary()); await context.Response.WriteAsync($"{path1} is match? {isMatch1}\n"); } catch (Exception ex) { await context.Response.WriteAsync($"Oops {path1}: {ex?.Message}\n\n"); } finally { await next.Invoke(); } }); app.Use(async(context, next) => { var path1 = "/hello/world"; var isMatch1 = templateMatcher.TryMatch(path1, new RouteValueDictionary()); await context.Response.WriteAsync($"{path1} is match? {isMatch1}\n"); await next.Invoke(); }); app.Use(async(context, next) => { var path1 = "/hello/"; var isMatch1 = templateMatcher.TryMatch(path1, new RouteValueDictionary()); await context.Response.WriteAsync($"{path1} is match? {isMatch1}\n"); await next.Invoke(); }); app.Run(async context => { await context.Response.WriteAsync(""); }); }
public static void MatchedTemplate(ILogger logger, HttpContext httpContext, RouteTemplate template) { _matchedTemplate(logger, httpContext.Request.Path, template.TemplateText, null); }
public RouteEntry(RouteTemplate template, [DynamicallyAccessedMembers(Component)] Type handler, List <string>?unusedRouteParameterNames) { Template = template; UnusedRouteParameterNames = unusedRouteParameterNames; Handler = handler; }
public override TemplateBinder Create(RouteTemplate template, RouteValueDictionary defaults) { return(null); }
/// <summary> /// Returns a string that represents the current object. /// </summary> /// <returns> /// A string that represents the current object. /// </returns> public override string ToString() { return ($"{RequestId}::{Method.ToUpperInvariant()} {Host.ToLowerInvariant()}{RouteTemplate.ToLowerInvariant()}::{_getSuffix(_dateTimeUtcNow)}"); }