Docs have broken sample code
invalid codegood first issue
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.
关闭于 2025-11-03 4 条评论