Skip to content

Commit

Permalink
fix nim 0.20 and 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Sep 23, 2019
1 parent 306ec5b commit e146b54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions openapi.nimble
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version = "2.0.0"
version = "2.0.1"
author = "disruptek"
description = "OpenAPI Code Generator"
license = "MIT"
requires "nim >= 1.0.0"
requires "nim >= 0.20.0"
requires "npeg >= 0.14.0"
requires "foreach >= 1.0.1"

Expand Down
11 changes: 9 additions & 2 deletions src/openapi/rest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ method newRecallable*(call: RestCall; url: Uri): Recallable
## make a new HTTP request that we can reissue if desired
result = newRecallable(call, url, newHttpHeaders(), "")

# a hack to work around nim 0.20 -> 1.0 interface change
template isEmptyAnyVersion(h: HttpHeaders): bool =
when compiles(h.isEmpty):
h.isEmpty
else:
h == nil

proc issueRequest*(rec: Recallable): Future[AsyncResponse]
{.raises: [AsyncError].} =
## submit a request and store some metrics
Expand All @@ -176,9 +183,9 @@ proc issueRequest*(rec: Recallable): Future[AsyncResponse]
#
# FIXME move this header-fu into something restClient-specific
#
if not rec.headers.isEmpty:
if not rec.headers.isEmptyAnyVersion:
rec.client.http.headers = rec.headers
elif not rec.client.headers.isEmpty:
elif not rec.client.headers.isEmptyAnyVersion:
rec.client.http.headers = rec.client.headers
else:
rec.client.http.headers = newHttpHeaders()
Expand Down

0 comments on commit e146b54

Please sign in to comment.