FHIRRequestHandler
public protocol FHIRRequestHandler
Protocol for different request/response handlers.
TODO: should add ResponseType
associated type as soon as those can be constrained (SE-0142 – Swift 4?).
-
The HTTP method of the request.
Declaration
Swift
var method: FHIRRequestMethod
-
Headers to be used on the request.
Declaration
Swift
var headers: FHIRRequestHeaders
-
Request parameters to pass along.
Declaration
Swift
var parameters: FHIRRequestParameters
-
Request options to pass along.
Declaration
Swift
var options: FHIRRequestOption
-
The receiver may hold on to a resource that supplies the request’s body data.
Declaration
Swift
var resource: Resource?
-
Designated initializer.
Declaration
Swift
init(_ method: FHIRRequestMethod, resource: Resource?)
-
Add the given headers to the request, overwriting existing headers.
Declaration
Swift
func add(headers inHeaders: FHIRRequestHeaders)
Parameters
headers
The headers to add to the receiver
-
Give the receiver a chance to prepare/alter the URL request.
For example, this method will tell the FHIRRequestMethod instance to set the correct HTTPMethod as well as FHIR headers.
Declaration
Swift
func prepare(request: inout URLRequest) throws
Parameters
request
The request to decorate
-
Instantiate a FHIRServerResponse based on the response and data that we get.
Declaration
Swift
func response(response: URLResponse?, data: Data?, error: Error?) -> FHIRServerResponse
Parameters
response
The URLResponse resulting from the request, if any
data
The data that was returned, if any
error
The error that was reported, if any
Return Value
An appropriately configured
FHIRServerResponse
instance -
Convenience method to indicate a request that has not actually been sent.
Declaration
Swift
func notSent(_ reason: String) -> FHIRServerResponse
Parameters
reason
Why the request was not sent
Return Value
An appropriately configured
FHIRServerResponse
instance