1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright (c) 2026 Hamze Ghalebi. All rights reserved.
// Licensed under the Rustlift Non-Commercial Licence v1.0.
//! Axum HTTP server deployed to Azure Web Apps.
//!
//! This is the **runtime binary** that Rustlift deploys. It is a minimal
//! Axum application exposing two endpoints:
//!
//! | Route | Method | Status | Purpose |
//! |-----------|--------|--------|----------------------------------|
//! | `/` | GET | `200` | Welcome message |
//! | `/health` | GET | `200` | Liveness probe for Azure and LB |
//!
//! # Environment
//!
//! | Variable | Required | Default | Description |
//! |----------|----------|---------|----------------------------------|
//! | `PORT` | no | `8080` | TCP port to bind |
//!
//! Azure App Service injects `WEBSITES_PORT=8080` and routes external
//! traffic through its load balancer. For local development, the server
//! defaults to port `8080` when `PORT` is not set.
//!
//! # Learning: Axum Basics
//!
//! [Axum](https://docs.rs/axum) is a Rust web framework built on top of
//! [`hyper`](https://docs.rs/hyper) and [`tokio`](https://docs.rs/tokio).
//!
//! The core idea is simple:
//!
//! 1. Create a [`Router`] — this maps URL paths to handler
//! functions.
//! 2. Define **handler functions** — these are plain async functions whose
//! return type implements `IntoResponse`.
//! 3. Bind to a [`TcpListener`](tokio::net::TcpListener) and serve.
//!
//! Axum does not use macros for route definitions (unlike Actix Web).
//! Routes are composed via method chaining, which makes them easy to
//! read and refactor.
use ;
use SocketAddr;
use info;
/// Entry point for the deployed server binary.
///
/// Initialises logging, builds the router, and binds to the configured
/// port. The function blocks until the server is shut down.
///
/// # Panics
///
/// - If `PORT` is set to a value that cannot be parsed as a `u16`.
/// - If the TCP listener fails to bind (e.g. port already in use).
/// - If the server exits unexpectedly (all three are fatal for a
/// deployment binary — there is no meaningful recovery).
async
/// Root handler — returns a simple welcome message.
///
/// # Learning: Handler Return Types
///
/// In Axum, any type that implements `IntoResponse` can be returned from
/// a handler. `&'static str` implements this trait, so a plain string
/// literal becomes an HTTP 200 response with `text/plain` content type.
async
/// Health probe endpoint consumed by Azure's startup probe and the
/// platform load balancer.
///
/// Returning a short `"OK"` string keeps response sizes minimal. The
/// deployment agent's health-check step polls this endpoint after
/// deploying to verify that the application started successfully.
async