mirror of
https://github.com/benbusby/farside.git
synced 2025-04-20 02:48:42 +00:00
Include query params in service instance redirect
Query params ("/watch?v=dQw4w9WgXcQ" for instance) would previously be lost in Farside redirects. This now includes them if they were included in the original request.
This commit is contained in:
parent
8ce5b04f51
commit
97f1d26cbc
1 changed files with 10 additions and 1 deletions
|
@ -28,12 +28,21 @@ defmodule Farside.Router do
|
||||||
path = Enum.join(glob, "/")
|
path = Enum.join(glob, "/")
|
||||||
instance = Farside.pick_instance(service)
|
instance = Farside.pick_instance(service)
|
||||||
|
|
||||||
|
params =
|
||||||
|
cond do
|
||||||
|
String.length(conn.query_string) > 0 ->
|
||||||
|
"?#{conn.query_string}"
|
||||||
|
|
||||||
|
true ->
|
||||||
|
""
|
||||||
|
end
|
||||||
|
|
||||||
# Redirect to the available instance
|
# Redirect to the available instance
|
||||||
conn
|
conn
|
||||||
|> Plug.Conn.resp(:found, "")
|
|> Plug.Conn.resp(:found, "")
|
||||||
|> Plug.Conn.put_resp_header(
|
|> Plug.Conn.put_resp_header(
|
||||||
"location",
|
"location",
|
||||||
"#{instance}/#{path}"
|
"#{instance}/#{path}#{params}"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue