If you look at https://api.vapor.codes/vapor/documentation/vapor/niohttp1/httpheaders/accept#discussion, you will see the following sample code:
You can access all MediaTypes in this collection to check membership.
httpReq.accept.mediaTypes.contains(.html)
This has two issues: first, accept is available on httpReq.headers not directly on httpReq; and second, mediaTypes.contains only accepts a predicate-closure, not an HTTPMediaType as is shown.
Tested with swift 6.2 due to needing new macOS apis for my project.
If you look at https://api.vapor.codes/vapor/documentation/vapor/niohttp1/httpheaders/accept#discussion, you will see the following sample code:
You can access all MediaTypes in this collection to check membership.
httpReq.accept.mediaTypes.contains(.html)This has two issues: first, accept is available on
httpReq.headersnot directly onhttpReq; and second,mediaTypes.containsonly accepts a predicate-closure, not anHTTPMediaTypeas is shown.Tested with swift 6.2 due to needing new macOS apis for my project.