Skip to content

Commit

Permalink
Fix preferredContentType() function declaration to avoid confusion wi…
Browse files Browse the repository at this point in the history
…th `preferredContentType(varargs)`.
  • Loading branch information
cheatfate committed Oct 21, 2021
1 parent 59b91bf commit 2e57ddb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions chronos/apps/http/httpserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
##
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 2e57ddb

Please sign in to comment.