Skip to content

Commit 38c43b3

Browse files
committed
Removed [RouteAttribute].DefaultContentType as the functionality is not implemented internally
1 parent 34ae0f8 commit 38c43b3

File tree

10 files changed

+47
-145
lines changed

10 files changed

+47
-145
lines changed

src/ServiceStack.Interfaces/ServiceHost/IRestPath.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ public interface IRestPath
77
{
88
Type RequestType { get; }
99

10-
string DefaultContentType { get; }
11-
1210
object CreateRequest(string pathInfo, Dictionary<string, string> queryStringAndFormData, object fromInstance);
1311
}
1412
}

src/ServiceStack.Interfaces/ServiceHost/IServiceRoutes.cs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,6 @@ public interface IServiceRoutes
3535
/// never <see langword="null"/>.</returns>
3636
IServiceRoutes Add<TRequest>(string restPath, string verbs);
3737

38-
/// <summary>
39-
/// Maps the specified REST path to the specified request DTO,
40-
/// specifies the HTTP verbs supported by the path, and indicates
41-
/// the default MIME type of the returned response.
42-
/// </summary>
43-
/// <typeparam name="TRequest">The type of request DTO to map
44-
/// the path to.</typeparam>
45-
/// <param name="restPath">The path to map the request DTO to.
46-
/// See <see cref="RestServiceAttribute.Path">RestServiceAttribute.Path</see>
47-
/// for details on the correct format.</param>
48-
/// <param name="verbs">
49-
/// The comma-delimited list of HTTP verbs supported by the path,
50-
/// such as "GET,PUT,DELETE".
51-
/// </param>
52-
/// <param name="defaultContentType">
53-
/// The default MIME type in which the response object returned to the client
54-
/// is formatted, if formatting hints are not provided by the client.
55-
/// Specify <see langword="null"/> or empty to require formatting hints from
56-
/// the client.
57-
/// </param>
58-
/// <returns>The same <see cref="IServiceRoutes"/> instance;
59-
/// never <see langword="null"/>.</returns>
60-
IServiceRoutes Add<TRequest>(string restPath, string verbs, string defaultContentType);
61-
6238
/// <summary>
6339
/// Maps the specified REST path to the specified request DTO,
6440
/// specifies the HTTP verbs supported by the path, and indicates
@@ -74,14 +50,8 @@ public interface IServiceRoutes
7450
/// The comma-delimited list of HTTP verbs supported by the path,
7551
/// such as "GET,PUT,DELETE".
7652
/// </param>
77-
/// <param name="defaultContentType">
78-
/// The default MIME type in which the response object returned to the client
79-
/// is formatted, if formatting hints are not provided by the client.
80-
/// Specify <see langword="null"/> or empty to require formatting hints from
81-
/// the client.
82-
/// </param>
8353
/// <returns>The same <see cref="IServiceRoutes"/> instance;
8454
/// never <see langword="null"/>.</returns>
85-
IServiceRoutes Add(System.Type requestType, string restPath, string verbs, string defaultContentType);
55+
IServiceRoutes Add(System.Type requestType, string restPath, string verbs);
8656
}
8757
}

src/ServiceStack.Interfaces/ServiceHost/RestServiceAttribute.cs

Lines changed: 31 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,36 @@ namespace ServiceStack.ServiceHost
88
/// each request DTO, to map multiple paths to the service.
99
/// </summary>
1010
[Obsolete("Use [Route] instead of [RestService].")]
11-
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
12-
public class RestServiceAttribute
13-
: RouteAttribute
14-
{
15-
/// <summary>
16-
/// <para>Initializes an instance of the <see cref="RestServiceAttribute"/> class.</para>
17-
/// </summary>
18-
/// <param name="path">
19-
/// <para>The path template to map to the request. See
20-
/// <see cref="Path">RestServiceAttribute.Path</see>
21-
/// for details on the correct format.</para>
22-
/// </param>
23-
public RestServiceAttribute(string path)
24-
: base(path, null, null)
25-
{
26-
}
27-
28-
/// <summary>
29-
/// <para>Initializes an instance of the <see cref="RestServiceAttribute"/> class.</para>
30-
/// </summary>
31-
/// <param name="path">
32-
/// <para>The path template to map to the request. See
33-
/// <see cref="Path">RestServiceAttribute.Path</see>
34-
/// for details on the correct format.</para>
35-
/// </param>
36-
/// <param name="verbs">A comma-delimited list of HTTP verbs supported by the
37-
/// service. If unspecified, all verbs are assumed to be supported.</param>
38-
public RestServiceAttribute(string path, string verbs)
39-
: base(path, verbs, null)
40-
{
41-
}
42-
43-
/// <summary>
44-
/// <para>Initializes an instance of the <see cref="RestServiceAttribute"/> class.</para>
45-
/// </summary>
46-
/// <param name="path">
47-
/// <para>The path template to map to the request. See
48-
/// <see cref="Path">RestServiceAttribute.Path</see>
49-
/// for details on the correct format.</para>
50-
/// </param>
51-
/// <param name="verbs">A comma-delimited list of HTTP verbs supported by the
52-
/// service. If unspecified, all verbs are assumed to be supported.</param>
53-
/// <param name="defaultContentType">The default MIME type in which the response
54-
/// object returned to the client is formatted, if formatting hints are unspecified
55-
/// in the URL. Specify <see langword="null"/> or empty to require formatting
56-
/// hints from the client.</param>
57-
public RestServiceAttribute(string path, string verbs, string defaultContentType)
58-
: base(path, verbs, defaultContentType)
59-
{
60-
}
61-
}
11+
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
12+
public class RestServiceAttribute
13+
: RouteAttribute
14+
{
15+
/// <summary>
16+
/// <para>Initializes an instance of the <see cref="RestServiceAttribute"/> class.</para>
17+
/// </summary>
18+
/// <param name="path">
19+
/// <para>The path template to map to the request. See
20+
/// <see cref="Path">RestServiceAttribute.Path</see>
21+
/// for details on the correct format.</para>
22+
/// </param>
23+
public RestServiceAttribute(string path)
24+
: base(path, null)
25+
{
26+
}
6227

28+
/// <summary>
29+
/// <para>Initializes an instance of the <see cref="RestServiceAttribute"/> class.</para>
30+
/// </summary>
31+
/// <param name="path">
32+
/// <para>The path template to map to the request. See
33+
/// <see cref="Path">RestServiceAttribute.Path</see>
34+
/// for details on the correct format.</para>
35+
/// </param>
36+
/// <param name="verbs">A comma-delimited list of HTTP verbs supported by the
37+
/// service. If unspecified, all verbs are assumed to be supported.</param>
38+
public RestServiceAttribute(string path, string verbs)
39+
: base(path, verbs)
40+
{
41+
}
42+
}
6343
}

src/ServiceStack.Interfaces/ServiceHost/RouteAttribute.cs

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class RouteAttribute : Attribute
2222
/// for details on the correct format.</para>
2323
/// </param>
2424
public RouteAttribute(string path)
25-
: this(path, null, null)
25+
: this(path, null)
2626
{
2727
}
2828

@@ -37,29 +37,9 @@ public RouteAttribute(string path)
3737
/// <param name="verbs">A comma-delimited list of HTTP verbs supported by the
3838
/// service. If unspecified, all verbs are assumed to be supported.</param>
3939
public RouteAttribute(string path, string verbs)
40-
: this(path, verbs, null)
4140
{
42-
}
43-
44-
/// <summary>
45-
/// <para>Initializes an instance of the <see cref="RouteAttribute"/> class.</para>
46-
/// </summary>
47-
/// <param name="path">
48-
/// <para>The path template to map to the request. See
49-
/// <see cref="Path">RouteAttribute.Path</see>
50-
/// for details on the correct format.</para>
51-
/// </param>
52-
/// <param name="verbs">A comma-delimited list of HTTP verbs supported by the
53-
/// service. If unspecified, all verbs are assumed to be supported.</param>
54-
/// <param name="defaultContentType">The default MIME type in which the response
55-
/// object returned to the client is formatted, if formatting hints are unspecified
56-
/// in the URL. Specify <see langword="null"/> or empty to require formatting
57-
/// hints from the client.</param>
58-
public RouteAttribute(string path, string verbs, string defaultContentType)
59-
{
60-
Path = path;
61-
Verbs = verbs;
62-
DefaultContentType = defaultContentType;
41+
Path = path;
42+
Verbs = verbs;
6343
}
6444

6545
/// <summary>
@@ -120,18 +100,5 @@ public RouteAttribute(string path, string verbs, string defaultContentType)
120100
/// by the service, <see langword="null"/> or empty if all verbs are supported.
121101
/// </value>
122102
public string Verbs { get; set; }
123-
124-
/// <summary>
125-
/// Gets or sets the default MIME type in which the response
126-
/// object returned to the client is formatted, when format hints
127-
/// are not provided in the URI. Some valid examples are such as
128-
/// "application/json", or "application/xml".
129-
/// </summary>
130-
/// <value>
131-
/// A <see cref="String"/> providing the default MIME type of the response;
132-
/// <see langword="null"/> or empty if formatting hints are required
133-
/// from the client.
134-
/// </value>
135-
public string DefaultContentType { get; set; }
136103
}
137104
}

src/ServiceStack.ServiceInterface/ServiceRoutesExtensions.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ from t in assembly.GetExportedTypes()
8181
allowedVerbs = string.Join(" ", allowedMethods.ToArray());
8282
}
8383

84-
routes.Add(requestType, requestType.Name, allowedVerbs, null);
84+
routes.Add(requestType, requestType.Name, allowedVerbs);
8585

8686
var hasIdField = requestType.GetProperty(IdUtils.IdField) != null;
8787
if (hasIdField)
8888
{
8989
var routePath = requestType.Name + "/{" + IdUtils.IdField + "}";
90-
routes.Add(requestType, routePath, allowedVerbs, null);
90+
routes.Add(requestType, routePath, allowedVerbs);
9191
}
9292
}
9393
}
@@ -100,14 +100,9 @@ public static IServiceRoutes Add<TRequest>(this IServiceRoutes routes, string re
100100
return routes.Add<TRequest>(restPath, verbs.ToVerbsString());
101101
}
102102

103-
public static IServiceRoutes Add<TRequest>(this IServiceRoutes routes, string restPath, ApplyTo verbs, string defaultContentType)
103+
public static IServiceRoutes Add(this IServiceRoutes routes, Type requestType, string restPath, ApplyTo verbs)
104104
{
105-
return routes.Add<TRequest>(restPath, verbs.ToVerbsString(), defaultContentType);
106-
}
107-
108-
public static IServiceRoutes Add(this IServiceRoutes routes, Type requestType, string restPath, ApplyTo verbs, string defaultContentType)
109-
{
110-
return routes.Add(requestType, restPath, verbs.ToVerbsString(), defaultContentType);
105+
return routes.Add(requestType, restPath, verbs.ToVerbsString());
111106
}
112107

113108
private static string ToVerbsString(this ApplyTo verbs)

src/ServiceStack/ServiceHost/RestPath.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class RestPath
2020

2121
readonly bool[] componentsWithSeparators = new bool[0];
2222

23-
public string DefaultContentType { get; private set; }
2423
private readonly string restPath;
2524
private readonly string allowedVerbs;
2625
private readonly bool allowsAllVerbs;
@@ -86,14 +85,13 @@ private static IEnumerable<string> GetPotentialMatchesWithPrefix(string hashPref
8685
}
8786
}
8887

89-
public RestPath(Type requestType, string path) : this(requestType, path, null, null) { }
88+
public RestPath(Type requestType, string path) : this(requestType, path, null) { }
9089

91-
public RestPath(Type requestType, string path, string verbs, string defaultContentType)
90+
public RestPath(Type requestType, string path, string verbs)
9291
{
9392
this.RequestType = requestType;
9493

9594
this.restPath = path;
96-
this.DefaultContentType = defaultContentType;
9795
this.allowsAllVerbs = verbs == null || verbs == WildCard;
9896
if (!this.allowsAllVerbs)
9997
{

src/ServiceStack/ServiceHost/ServiceController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void RegisterRestPaths(Type requestType)
136136
var attrs = requestType.GetCustomAttributes(typeof(RouteAttribute), true);
137137
foreach (RouteAttribute attr in attrs)
138138
{
139-
var restPath = new RestPath(requestType, attr.Path, attr.Verbs, attr.DefaultContentType);
139+
var restPath = new RestPath(requestType, attr.Path, attr.Verbs);
140140
if (!restPath.IsValid)
141141
throw new NotSupportedException(string.Format(
142142
"RestPath '{0}' on Type '{1}' is not Valid", attr.Path, requestType.Name));

src/ServiceStack/ServiceHost/ServiceRoutes.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,13 @@ public IServiceRoutes Add<TRequest>(string restPath)
1515

1616
public IServiceRoutes Add<TRequest>(string restPath, string verbs)
1717
{
18-
RestPaths.Add(new RestPath(typeof(TRequest), restPath, verbs, null));
18+
RestPaths.Add(new RestPath(typeof(TRequest), restPath, verbs));
1919
return this;
2020
}
2121

22-
public IServiceRoutes Add<TRequest>(string restPath, string verbs, string defaultContentType)
23-
{
24-
RestPaths.Add(new RestPath(typeof(TRequest), restPath, verbs, defaultContentType));
25-
return this;
26-
}
27-
28-
public IServiceRoutes Add(Type requestType, string restPath, string verbs, string defaultContentType)
22+
public IServiceRoutes Add(Type requestType, string restPath, string verbs)
2923
{
30-
RestPaths.Add(new RestPath(requestType, restPath, verbs, defaultContentType));
24+
RestPaths.Add(new RestPath(requestType, restPath, verbs));
3125
return this;
3226
}
3327
}

src/ServiceStack/WebHost.Endpoints/AppHostBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public void RegisterService(Type serviceType, params string[] atRestPaths)
234234
var requestType = genericService.GetGenericArguments()[0];
235235
foreach (var atRestPath in atRestPaths)
236236
{
237-
this.Routes.Add(requestType, atRestPath, null, null);
237+
this.Routes.Add(requestType, atRestPath, null);
238238
}
239239
}
240240

src/ServiceStack/WebHost.Endpoints/Support/HttpListenerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public void RegisterService(Type serviceType, params string[] atRestPaths)
413413
var requestType = genericService.GetGenericArguments()[0];
414414
foreach (var atRestPath in atRestPaths)
415415
{
416-
this.Routes.Add(requestType, atRestPath, null, null);
416+
this.Routes.Add(requestType, atRestPath, null);
417417
}
418418
}
419419

0 commit comments

Comments
 (0)