|
103 | 103 |
|
104 | 104 | function set_mode(req) |
105 | 105 | 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, '/')) |
107 | 108 | if mode == "classic" |
108 | 109 | MODE[] = CLASSIC_MODE |
109 | 110 | elseif mode == "device" |
@@ -199,7 +200,16 @@ HTTP.register!(router, "POST", "/auth/device/code", auth_device_code) |
199 | 200 | HTTP.register!(router, "GET", "/auth/device", auth_device) |
200 | 201 | HTTP.register!(router, "POST", "/auth/token", auth_token) |
201 | 202 | 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 |
203 | 213 |
|
204 | 214 | function run() |
205 | 215 | println("starting server") |
|
0 commit comments