Fix preferredContentType() function declaration to avoid confusion with `preferredContentType(varargs)`.

This commit is contained in:
cheatfate 2021-10-21 14:01:46 +03:00
parent 59b91bf0ca
commit 2e57ddb455
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
1 changed files with 4 additions and 4 deletions

View File

@ -485,7 +485,7 @@ proc preferredContentMediaType*(acceptHeader: string): MediaType =
MediaType.init("*", "*")
proc preferredContentType*(acceptHeader: string,
types: varargs[string]): Result[string, cstring] =
types: openArray[string] = []): Result[string, cstring] =
## Match or obtain preferred content-type using ``Accept`` header specified by
## string ``acceptHeader``.
##
@ -519,8 +519,8 @@ proc preferredContentType*(acceptHeader: string,
# If `Accept` header is missing, client accepts any type of content.
ok(types[0])
else:
let res = getAcceptInfo(acceptHeader)
if res.isErr():
let ares = getAcceptInfo(acceptHeader)
if ares.isErr():
# If `Accept` header is incorrect, client accepts any type of content.
ok(types[0])
else:
@ -530,7 +530,7 @@ proc preferredContentType*(acceptHeader: string,
for item in types:
res.add(MediaType.init(item))
res
for item in res.get().data:
for item in ares.get().data:
for expect in mediaTypes:
if expect == item.mediaType:
return ok($expect)