Genie.jl icon indicating copy to clipboard operation
Genie.jl copied to clipboard

Route to reach external URL

Open tpoisot opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. I'm trying to use OAuth2 login but cannot setup my routes in a way that brings me to my authentication website

Describe the solution you'd like

route("/login", Genie.Renderer.redirect(:orcid_login))

tpoisot avatar Nov 15 '21 19:11 tpoisot

The problem is route expects a reference to a function. When you pass Genie.Renderer.redirect(:orcid_login) you don't pass the function, you pass the result of executing the function, which is a HTTP.Response.

Try

route("/login") do 
  Genie.Renderer.redirect("<url_to_external_oauth_service_or_whatever_you_need>")
end

essenciary avatar Nov 16 '21 19:11 essenciary

That works, thanks! I think the nuance that route expects a reference to a function is super important, and I didn't quite got this from the docs.

tpoisot avatar Nov 16 '21 21:11 tpoisot