From 9107e551f1a617d5c3d0c3dfef44c91422a1dd07 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 28 Apr 2017 19:09:11 +0300 Subject: close #5726 Turned out that the old code was wrong. I'm not sure why it used to work. `response.body` properly resolves to an async proc defined in the httpclient module with the following signature: proc body*(response: AsyncResponse): Future[string] {.async.} Perhaps the old code was somehow matching the body field of the `AsyncResponse` object, which is marked as private. --- web/bountysource.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'web') diff --git a/web/bountysource.nim b/web/bountysource.nim index 1d47cea56..8d4f36bf0 100644 --- a/web/bountysource.nim +++ b/web/bountysource.nim @@ -29,17 +29,19 @@ proc newBountySource(team, token: string): BountySource = result.client.headers["Referer"] = "https://salt.bountysource.com/teams/nim/admin/supporters" result.client.headers["Origin"] = "https://salt.bountysource.com/" +import typetraits + proc getSupporters(self: BountySource): Future[JsonNode] {.async.} = let response = await self.client.get(apiUrl & "/supporters?order=monthly&per_page=200&team_slug=" & self.team) doAssert response.status.startsWith($Http200) - return parseJson(response.body) + return parseJson(await response.body) proc getGithubUser(username: string): Future[JsonNode] {.async.} = let client = newAsyncHttpClient() let response = await client.get(githubApiUrl & "/users/" & username) if response.status.startsWith($Http200): - return parseJson(response.body) + return parseJson(await response.body) else: echo("Could not get Github user: ", username, ". ", response.status) return nil -- cgit 1.4.1-2-gfad0 From 622100adb6deb75cfb0fad4e4e94af9f0d7a232c Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 30 Apr 2017 21:57:13 +0300 Subject: close #5757 --- tests/stdlib/tmarshal.nim | 24 +++++++++++++++++++++++- web/bountysource.nim | 2 -- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'web') diff --git a/tests/stdlib/tmarshal.nim b/tests/stdlib/tmarshal.nim index b05cb5a10..6a53a2964 100644 --- a/tests/stdlib/tmarshal.nim +++ b/tests/stdlib/tmarshal.nim @@ -1,7 +1,10 @@ discard """ output: '''{"age": 12, "bio": "\u042F Cletus", "blob": [65, 66, 67, 128], "name": "Cletus"} true -true''' +true +alpha 100 +omega 200 +''' """ import marshal @@ -83,3 +86,22 @@ var instance1 = Person(name: "Cletus", age: 12, echo($$instance1) echo(to[Person]($$instance1).bio == instance1.bio) echo(to[Person]($$instance1).blob == instance1.blob) + +# bug 5757 + +type + Something = object + x: string + y: int + +var data1 = """{"x": "alpha", "y": 100}""" +var data2 = """{"x": "omega", "y": 200}""" + +var r = to[Something](data1) + +echo r.x, " ", r.y + +r = to[Something](data2) + +echo r.x, " ", r.y + diff --git a/web/bountysource.nim b/web/bountysource.nim index 8d4f36bf0..5dfdb4497 100644 --- a/web/bountysource.nim +++ b/web/bountysource.nim @@ -29,8 +29,6 @@ proc newBountySource(team, token: string): BountySource = result.client.headers["Referer"] = "https://salt.bountysource.com/teams/nim/admin/supporters" result.client.headers["Origin"] = "https://salt.bountysource.com/" -import typetraits - proc getSupporters(self: BountySource): Future[JsonNode] {.async.} = let response = await self.client.get(apiUrl & "/supporters?order=monthly&per_page=200&team_slug=" & self.team) -- cgit 1.4.1-2-gfad0