Skip to content

Convert POST request body to Dict #59

@jeremiahpslewis

Description

@jeremiahpslewis

Thanks for the great library!

Is it possible to convert the body of a Request to a dictionary when responding to a POST request?

using HTTP
function handle_post(req::Request, rep::Response)
   String(take!(req)) # convert to Dict here
   return rep::Response
end

server = HTTP.Server(handle_post)
tsk = @async HTTP.serve(server, ip"0.0.0.0", 5000, verbose=true)

sleep(2)
r = HTTP.post("http://0.0.0.0:5000", body=Dict("amount"=> 1000))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions