Skip to content

Commit f0aef60

Browse files
committed
web: add restart handler + action button
1 parent a1e2201 commit f0aef60

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/web.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub fn app(state: Arc<AppState>) -> Router {
2828
.route("/", get(index))
2929
.route("/config", get(get_config).post(set_config))
3030
.route("/download", get(download_handler))
31+
.route("/restart", get(restart_handler))
3132
.with_state(state)
3233
}
3334

@@ -45,6 +46,15 @@ fn generate_filename() -> String {
4546
now.format("%Y%m%d%H%M%S_aa-proxy-rs.log").to_string()
4647
}
4748

49+
async fn restart_handler(State(state): State<Arc<AppState>>) -> impl IntoResponse {
50+
state.config.write().await.restart_requested = true;
51+
52+
Response::builder()
53+
.status(StatusCode::OK)
54+
.body(Body::from("Restart has been requested"))
55+
.unwrap()
56+
}
57+
4858
async fn download_handler(
4959
State(state): State<Arc<AppState>>,
5060
Query(params): Query<HashMap<String, String>>,

static/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ <h3>🛸 aa-proxy-rs</h3>
2424
<tr>
2525
<td colspan="2">
2626
<button type="button" id="downloadBtn">📥 Download log</button>
27+
<button type="button" onclick="window.location.href='/restart'">
28+
🧬 Apply / restart
29+
</button>
2730
</td>
2831
</tr>
2932
<tr>

0 commit comments

Comments
 (0)