Create a CORS example
Hi, do you have any pointers for this, I need to return an Access-Control-Allow-Origin header.
Ok I figured it out:
function addHeaders(res::HTTP.Response)
push!(res.headers, Pair("Access-Control-Allow-Origin", "*"))
push!(res.headers, Pair("Content-Type", "application/json"))
return res
end
Endpoint("/withheadersyeay") do request::HTTP.Request
if request.method == "GET"
ret=Dict("some"=>"response data"))
return addHeaders(HTTP.Response(200, JSON.json(ret)))
end
unsupported()
end
I can make a pullrequest for this issue if you like. I'm thinking to just add another endpoint to examples/requests.jl with the headers added as above?
I really like Pages.jl .
finally solved utf-8 encoding problem ( by adding charset as header ) much tnx~
Oh wow. I'm sorry @amanica . Somehow I completely missed your comments 😅
No worries, I'm finally busy porting to Julia1 :)
On Fri, 29 Mar 2019, 08:50 Eric Forgy, [email protected] wrote:
Oh wow. I'm sorry @amanica https://github.com/amanica . Somehow I completely missed your comments 😅
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EricForgy/Pages.jl/issues/11#issuecomment-477888886, or mute the thread https://github.com/notifications/unsubscribe-auth/AAz2qEsp8X96I45p-i7zr26o9snhUKWhks5vbbejgaJpZM4R4Eiv .