You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Response struct which can be used in `RouteHandlers` to provide valid responses.
37
+
A protocol to adopt when a Serializable Object needs to also provide response status code and/or headerFields
38
+
You may usually use `Response` to wrap your `Serializable` object to just achieve the result or directly implement the protocol. For examply `JSONAPISerializer` implement the protocol in order to be able to provide custom status code in the response.
/// An optional dictionary holding the response header fields
48
+
varheaderFields:[String:String]?{get}
49
+
}
50
+
51
+
extensionResponseFieldsProvider{
52
+
53
+
publicfunc customSerialize()->AnyObject?{
54
+
return body.serialize()
55
+
}
56
+
}
57
+
58
+
/**
59
+
A ResponseFieldsProvider implementation which can be used in `RouteHandlers` to provide valid responses that can return different status code than the default (200) or headerFields.
38
60
39
61
The struct provides, appart from a Serializable `body` object, a status code and header fields.
40
62
*/
41
-
publicstructResponse:CustomSerializable{
42
-
/// The response code
43
-
letcode:Int
63
+
publicstructResponse:ResponseFieldsProvider{
64
+
/// The response status code
65
+
publicletstatusCode:Int
44
66
45
67
/// The Serializable body object
46
-
letbody:Serializable
68
+
publicletbody:Serializable
47
69
48
70
/// An optional dictionary holding the response header fields
0 commit comments