Skip to content

Commit

Permalink
#146 - Add content-type to the route definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Feb 4, 2019
1 parent 415b7b2 commit b6ee920
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Neptuo.Net.Http.Routing/Routing/RelativeRouteTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public bool TryGet(Type inputType, out RouteDefinition route)
if (route.Url.StartsWith("~/"))
{
string relativeUrl = route.Url.Substring(1);
route = new RouteDefinition(baseUrl + relativeUrl, route.Method, route.Serializer);
route = new RouteDefinition(baseUrl + relativeUrl, route.Method, route.Serializer, route.ContentType);
return true;
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/Neptuo.Net.Http.Routing/Routing/RouteDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@ public class RouteDefinition
/// </summary>
public ISerializer Serializer { get; }

/// <summary>
/// Gets a content type for the route.
/// </summary>
public string ContentType { get; }

/// <summary>
/// Creates a new instance.
/// </summary>
/// <param name="url">A route URL.</param>
/// <param name="method">A HTTP method used for the route.</param>
/// <param name="serialization">A serializer for the route.</param>
public RouteDefinition(string url, RouteMethod method, ISerializer serializer)
/// <param name="serializer">A serializer for the route.</param>
/// <param name="contentType">A content type for the route.</param>
public RouteDefinition(string url, RouteMethod method, ISerializer serializer, string contentType)
{
Url = url;
Method = method;
Serializer = serializer;
ContentType = contentType;
}
}
}

0 comments on commit b6ee920

Please sign in to comment.