mirror of
https://github.com/benbusby/farside.git
synced 2025-03-15 03:36:33 -04: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
@ -28,12 +28,21 @@ defmodule Farside.Router do
|
||||
path = Enum.join(glob, "/")
|
||||
instance = Farside.pick_instance(service)
|
||||
|
||||
params =
|
||||
cond do
|
||||
String.length(conn.query_string) > 0 ->
|
||||
"?#{conn.query_string}"
|
||||
|
||||
true ->
|
||||
""
|
||||
end
|
||||
|
||||
# Redirect to the available instance
|
||||
conn
|
||||
|> Plug.Conn.resp(:found, "")
|
||||
|> Plug.Conn.put_resp_header(
|
||||
"location",
|
||||
"#{instance}/#{path}"
|
||||
"#{instance}/#{path}#{params}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user