1
0
Fork 0
mirror of https://github.com/benbusby/farside.git synced 2025-04-20 10:58:42 +00:00

Ignore request types in router

Request types don't really matter in Farside, and should be ignored.
This updates the router to handle all request types (GET, HEAD, POST,
etc) the same as GET requests were handled previously.
This commit is contained in:
Ben Busby 2022-12-11 13:14:40 -07:00
parent f91e490696
commit 2a858b89d2
No known key found for this signature in database
GPG key ID: B9B7231E01D924A1
2 changed files with 4 additions and 4 deletions

View file

@ -91,7 +91,7 @@ defmodule Farside do
# Either pick a random available instance, # Either pick a random available instance,
# or fall back to the default one # or fall back to the default one
instance = instance =
if Enum.count(instances) > 0 do if instances != nil && Enum.count(instances) > 0 do
if Enum.count(instances) == 1 do if Enum.count(instances) == 1 do
# If there's only one instance, just return that one... # If there's only one instance, just return that one...
List.first(instances) List.first(instances)

View file

@ -18,7 +18,7 @@ defmodule Farside.Router do
end end
end end
get "/" do match "/" do
resp = resp =
EEx.eval_file( EEx.eval_file(
@index, @index,
@ -29,7 +29,7 @@ defmodule Farside.Router do
send_resp(conn, 200, resp) send_resp(conn, 200, resp)
end end
get "/_/:service/*glob" do match "/_/:service/*glob" do
r_path = String.slice(conn.request_path, 2..-1) r_path = String.slice(conn.request_path, 2..-1)
resp = resp =
@ -41,7 +41,7 @@ defmodule Farside.Router do
send_resp(conn, 200, resp) send_resp(conn, 200, resp)
end end
get "/:service/*glob" do match "/:service/*glob" do
service_name = cond do service_name = cond do
service =~ "http" -> service =~ "http" ->
List.first(glob) List.first(glob)