Replies: 1 comment 1 reply
-
Having spent some more time pondering this, I've created the following, which seems to do what I needed (ie returns the entire query dictionary): /// Returns all the provided queries as a raw Fields object:
public struct AllQueries: Parser {
@inlinable
public func parse(_ input: inout URLRequestData) throws -> URLRequestData.Fields {
input.query
}
}
extension AllQueries: ParserPrinter {
public func print(_ output: URLRouting.URLRequestData.Fields, into input: inout URLRouting.URLRequestData) throws {
// Merge the two query lists, replacing existing values with the new ones:
input.query.fields.merge(output) { (_,new) in new }
}
} Have I made any blunders here? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Thanks for another great library. This one seems to be making my life a little easier, but I have a question about using unnamed queries.
I'm implementing a router for the FHIR API for health care interoperability to use in a client application. This API has a huge number of resource types we can access like
https://<host>/<base>/Patient/<identifier>
, but also provides the ability to search for these resources.The API defines a number of common search parameters that are all passed as queries, such as
_type
to limit the resource types to search, and_content
to search in all fields of the resource. But for each resource, the API permits other fields to search on, which are also passed as queries (given
orsurname
for a Patient, oringredient
for a Medication). R4 of the API defines 145 different resources, and each can have a number of search fields, and these numbers keep growing with later versions.Currently, I define the following as my routes:
and the parser body as:
Question: Is there a way to pass the unparsed query parameters, or the entire list of query parameters, to my
SearchParameters
struct?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions