Skip to content

Commit 796a166

Browse files
committed
fix for old Julia / HTTP
1 parent d54c3ec commit 796a166

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/authserver.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ end
103103

104104
function set_mode(req)
105105
global MODE
106-
mode = get(HTTP.getparams(req), "mode", nothing)
106+
# We want to grab the last path element of the '/set_mode/{mode}' URI
107+
mode = last(split(HTTP.URIs.URI(req.target).path, '/'))
107108
if mode == "classic"
108109
MODE[] = CLASSIC_MODE
109110
elseif mode == "device"
@@ -199,7 +200,16 @@ HTTP.register!(router, "POST", "/auth/device/code", auth_device_code)
199200
HTTP.register!(router, "GET", "/auth/device", auth_device)
200201
HTTP.register!(router, "POST", "/auth/token", auth_token)
201202
HTTP.register!(router, "GET", "/auth/renew/token.toml/device", renew_handler)
202-
HTTP.register!(router, "POST", "/set_mode/{mode}", set_mode)
203+
# We run tests on Julia 1.3-1.5, so we need to also support HTTP 0.9 server.
204+
# Unfortunately, HTTP 0.9 does not support variables in route paths, so
205+
# we can't do
206+
#
207+
# HTTP.register!(router, "POST", "/set_mode/{mode}", set_mode)
208+
#
209+
# So we hack around this.
210+
for mode in ["classic", "device", "device-no-scope"]
211+
HTTP.register!(router, "POST", "/set_mode/$(mode)", set_mode)
212+
end
203213

204214
function run()
205215
println("starting server")

0 commit comments

Comments
 (0)