forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomFormDataService.cs
More file actions
45 lines (37 loc) · 1.13 KB
/
CustomFormDataService.cs
File metadata and controls
45 lines (37 loc) · 1.13 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
using System.Runtime.Serialization;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceInterface.ServiceModel;
namespace ServiceStack.WebHost.IntegrationTests.Services
{
[RestService("/customformdata")]
[DataContract]
public class CustomFormData { }
[DataContract]
public class CustomFormDataResponse : IHasResponseStatus
{
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string Item0 { get; set; }
[DataMember]
public string Item1Delete { get; set; }
[DataMember]
public ResponseStatus ResponseStatus { get; set; }
}
public class CustomFormDataService
: RestServiceBase<CustomFormData> // which inherits from IRequiresRequestContext
{
//Parsing: &first-name=tom&item-0=blah&item-1-delete=1
public override object OnPost(CustomFormData request)
{
var httpReq = base.RequestContext.Get<IHttpRequest>();
return new CustomFormDataResponse
{
FirstName = httpReq.FormData["first-name"],
Item0 = httpReq.FormData["item-0"],
Item1Delete = httpReq.FormData["item-1-delete"]
};
}
}
}