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?).

  • 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