mirror of
https://github.com/benbusby/farside.git
synced 2025-04-19 06:45:55 -04:00
add status routes
This commit is contained in:
parent
d5c3ec736c
commit
ad2da6cdc6
@ -168,6 +168,10 @@ Farside's routing is very minimal, with only the following routes:
|
||||
jumping between instances by navigating back.
|
||||
- Ex: `/_/nitter` -> nitter instance A -> (navigate back one page) -> nitter
|
||||
instance B -> ...
|
||||
- `/status`
|
||||
- json of the instance data
|
||||
- `/backup`
|
||||
- download json of the instance data
|
||||
- *Note: Uses Javascript to preserve the page in history*
|
||||
|
||||
When a service is requested with the `/:service/...` endpoint, Farside requests
|
||||
|
@ -29,6 +29,26 @@ defmodule Farside.Router do
|
||||
send_resp(conn, 200, resp)
|
||||
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
|
||||
r_path = String.slice(conn.request_path, 2..-1)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
defmodule Service do
|
||||
@moduledoc nil
|
||||
|
||||
@derive Jason.Encoder
|
||||
defstruct type: nil,
|
||||
test_url: nil,
|
||||
fallback: nil,
|
||||
|
Loading…
x
Reference in New Issue
Block a user