rename routes to namespace them.

This commit is contained in:
Joe Ardent 2024-04-19 16:53:08 -07:00
parent 47d3fbc339
commit 72ca947cf6
4 changed files with 15 additions and 16 deletions

View file

@ -79,14 +79,17 @@ pub async fn app(db_pool: sqlx::SqlitePool) -> IntoMakeService<axum::Router> {
.route("/watches", get(get_watches)) .route("/watches", get(get_watches))
.route("/watch", get(get_watch)) .route("/watch", get(get_watch))
.route("/watch/:watch", get(get_watch)) .route("/watch/:watch", get(get_watch))
.route("/watch/status/:watch", get(get_watch_status))
.route("/quest/edit", post(edit_watch_quest))
.route("/title-search", get(get_search_watch))
.route("/add", get(get_add_new_watch).post(post_add_new_watch))
.route( .route(
"/add/watch", "/watch/add",
get(get_add_new_watch).post(post_add_new_watch),
)
.route("/watch/status/:watch", get(get_watch_status))
.route(
"/quest/add",
get(get_search_watch).post(post_add_watch_quest), get(get_search_watch).post(post_add_watch_quest),
) )
.route("/quest/edit", post(edit_watch_quest))
.route("/title-search", get(get_search_watch))
.fallback(handle_slash_redir) .fallback(handle_slash_redir)
.layer(middleware::from_fn_with_state( .layer(middleware::from_fn_with_state(
db_pool.clone(), db_pool.clone(),

View file

@ -231,12 +231,7 @@ pub async fn edit_watch_quest(
.into_response(), .into_response(),
) )
} else { } else {
// todo: return editerror that prompts a login Err(EditErrorKind::NotSignedIn.into())
let resp = Redirect::to("/login");
let mut resp = resp.into_response();
resp.headers_mut()
.insert("HX-Redirect", HeaderValue::from_str("/login").unwrap());
Ok(resp.into_response())
} }
} }

View file

@ -10,7 +10,7 @@
{% if user.is_some() %} {% if user.is_some() %}
<div class="add-watch"> <div class="add-watch">
<form action="/add" enctype="application/x-www-form-urlencoded" method="post"> <form action="/watch/add" enctype="application/x-www-form-urlencoded" method="post">
<label for="title">Title</label> <label for="title">Title</label>
<input type="text" name="title" id="title"></br> <input type="text" name="title" id="title"></br>
@ -45,7 +45,8 @@
{% else %} {% else %}
<div class="add-watch"> <div class="add-watch">
<span class="not-logged-in">Oh dang, you need to <a href="/login">login</a> or <a href="/signup">signup</a> to add something to watch!</span> <span class="not-logged-in">Oh dang, you need to <a href="/login">login</a> or <a href="/signup">signup</a> to add
something to watch!</span>
</div> </div>

View file

@ -55,7 +55,7 @@
{% when None %} {% when None %}
<form id="add-watch-{{self.watch}}"> <form id="add-watch-{{self.watch}}">
<button hx-post="/add/watch" hx-target="#add-watch-{{self.watch}}" hx-trigger="click" <button hx-post="/quest/add" hx-target="#add-watch-{{self.watch}}" hx-trigger="click"
hx-swap="outerHTML">add</button> hx-swap="outerHTML">add</button>
<select name="public" id="add-public-watch"> <select name="public" id="add-public-watch">
<option value="true">public</option> <option value="true">public</option>