forked from ServiceStackV3/ServiceStack.Contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentType.cs
More file actions
95 lines (66 loc) · 2.06 KB
/
ContentType.cs
File metadata and controls
95 lines (66 loc) · 2.06 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using ServiceStack.ServiceHost;
namespace ServiceStack.WebHost.Endpoints.Support
{
public class ContentType
{
public const string HeaderContentType = "Content-Type";
public const string FormUrlEncoded = "application/x-www-form-urlencoded";
public const string MultiPartFormData = "multipart/form-data";
public const string Html = "text/html";
public const string Xml = "application/xml";
public const string XmlText = "text/xml";
public const string Soap11 = " text/xml; charset=utf-8";
public const string Soap12 = " application/soap+xml";
public const string Json = "application/json";
public const string JsonText = "text/json";
public const string Jsv = "application/jsv";
public const string JsvText = "text/jsv";
public const string Csv = "text/csv";
public const string Yaml = "application/yaml";
public const string YamlText = "text/yaml";
public const string PlainText = "text/plain";
public const string ProtoBuf = "application/x-protobuf";
public static EndpointAttributes GetEndpointAttributes(string contentType)
{
switch (contentType)
{
case Json:
case JsonText:
return EndpointAttributes.Json;
case Xml:
case XmlText:
return EndpointAttributes.Xml;
case Html:
return EndpointAttributes.Html;
case Jsv:
case JsvText:
return EndpointAttributes.Jsv;
case Yaml:
case YamlText:
return EndpointAttributes.Yaml;
case Csv:
return EndpointAttributes.Csv;
}
throw new NotSupportedException(contentType);
}
public static string GetContentType(EndpointType endpointType)
{
switch (endpointType)
{
case EndpointType.Soap11:
case EndpointType.Soap12:
case EndpointType.Xml:
return Xml;
case EndpointType.Json:
return Json;
case EndpointType.Jsv:
return JsvText;
case EndpointType.ProtoBuf:
return ProtoBuf;
default:
throw new NotSupportedException(endpointType.ToString());
}
}
}
}