mirror of
https://github.com/benbusby/farside.git
synced 2025-06-08 02:16:36 +00:00
add status routes
This commit is contained in:
parent
d5c3ec736c
commit
ad2da6cdc6
3 changed files with 25 additions and 1 deletions
|
@ -168,6 +168,10 @@ Farside's routing is very minimal, with only the following routes:
|
||||||
jumping between instances by navigating back.
|
jumping between instances by navigating back.
|
||||||
- Ex: `/_/nitter` -> nitter instance A -> (navigate back one page) -> nitter
|
- Ex: `/_/nitter` -> nitter instance A -> (navigate back one page) -> nitter
|
||||||
instance B -> ...
|
instance B -> ...
|
||||||
|
- `/status`
|
||||||
|
- json of the instance data
|
||||||
|
- `/backup`
|
||||||
|
- download json of the instance data
|
||||||
- *Note: Uses Javascript to preserve the page in history*
|
- *Note: Uses Javascript to preserve the page in history*
|
||||||
|
|
||||||
When a service is requested with the `/:service/...` endpoint, Farside requests
|
When a service is requested with the `/:service/...` endpoint, Farside requests
|
||||||
|
|
|
@ -29,6 +29,26 @@ defmodule Farside.Router do
|
||||||
send_resp(conn, 200, resp)
|
send_resp(conn, 200, resp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/backup" do
|
||||||
|
resp = Jason.encode!(Farside.get_services_map())
|
||||||
|
|
||||||
|
conn =
|
||||||
|
conn
|
||||||
|
|> put_resp_content_type("application/json")
|
||||||
|
|> put_resp_header("content-disposition", "attachment; filename=farside.json")
|
||||||
|
|> Plug.Conn.send_resp(:ok, resp)
|
||||||
|
|
||||||
|
send_resp(conn, 200, resp)
|
||||||
|
end
|
||||||
|
|
||||||
|
get "/status" do
|
||||||
|
resp = Jason.encode!(Farside.get_services_map())
|
||||||
|
|
||||||
|
conn = conn |> merge_resp_headers([{"content-type", "application/json"}])
|
||||||
|
|
||||||
|
send_resp(conn, 200, resp)
|
||||||
|
end
|
||||||
|
|
||||||
get "/_/:service/*glob" do
|
get "/_/:service/*glob" do
|
||||||
r_path = String.slice(conn.request_path, 2..-1)
|
r_path = String.slice(conn.request_path, 2..-1)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
defmodule Service do
|
defmodule Service do
|
||||||
@moduledoc nil
|
@moduledoc nil
|
||||||
|
@derive Jason.Encoder
|
||||||
defstruct type: nil,
|
defstruct type: nil,
|
||||||
test_url: nil,
|
test_url: nil,
|
||||||
fallback: nil,
|
fallback: nil,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue