8000 JSON and Testing · Issue #97 · wookay/Bukdu.jl · GitHub
[go: up one dir, main page]

Skip to content

JSON and Testing #97

Closed
Closed

Description

@lucianolorenti

Hi! How are you?
I am facing the following issue. Suppouse that you have and enpoint that returns a JSON

using Bukdu
struct WelcomeController <: ApplicationController
    conn::Conn
end
index(c::WelcomeController) = render(JSON, Dict("something"=>[:hello_world, :goodbye_world]))
routes() do
    get("/", WelcomeController, index)
end
Bukdu.start(8080)

If I made a call from a browser to "/" I got:

{"something":["hello_world","goodbye_world"]}

But when I made a test case and I call the endpoing from julia doing:
julia> response = Bukdu.Router.call(get, "/")

I got:

julia> response.got
Dict{String,Array{Symbol,1}} with 1 entry:
  "something" => Symbol[:hello_world, :goodbye_world]

Is this an expected behaviour?

Activity

  1. wookay commented on Apr 3, 2020

    @wookay
    Owner

    yes, that's expected. if you want to take the result that like browser, use resp.body.

    julia> String(response.resp.body)
    "{\"something\":[\"hello_world\",\"goodbye_world\"]}"
  2. lucianolorenti commented on Apr 3, 2020

    @lucianolorenti
    Author

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0