Skip to content

Commit

Permalink
Update Axum, refactor HTTP endpoints (#1413)
Browse files Browse the repository at this point in the history
  • Loading branch information
spetz authored Jan 1, 2025
1 parent 68f7fca commit c04acf6
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 28 deletions.
70 changes: 61 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "server"
version = "0.4.95"
version = "0.4.96"
edition = "2021"
build = "src/build.rs"

Expand All @@ -14,7 +14,7 @@ ahash = { version = "0.8.11" }
anyhow = "1.0.95"
async-trait = "0.1.83"
atone = "0.3.7"
axum = "0.7.9"
axum = "0.8.1"
axum-server = { version = "0.7.1", features = ["tls-rustls"] }
bcrypt = "0.16.0"
bincode = "1.3.3"
Expand Down Expand Up @@ -56,7 +56,7 @@ opentelemetry_sdk = { version = "0.27.1", features = [
prometheus-client = "0.22.3"
quinn = { version = "0.11.6" }
rcgen = "0.13.2"
reqwest = { version = "0.12.11", features = [
reqwest = { version = "0.12.12", features = [
"rustls-tls",
"rustls-tls-no-provider",
] }
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/consumer_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ use tracing::instrument;
pub fn router(state: Arc<AppState>) -> Router {
Router::new()
.route(
"/streams/:stream_id/topics/:topic_id/consumer-groups",
"/streams/{stream_id}/topics/{topic_id}/consumer-groups",
get(get_consumer_groups).post(create_consumer_group),
)
.route(
"/streams/:stream_id/topics/:topic_id/consumer-groups/:group_id",
"/streams/{stream_id}/topics/{topic_id}/consumer-groups/{group_id}",
get(get_consumer_group).delete(delete_consumer_group),
)
.with_state(state)
Expand Down
2 changes: 1 addition & 1 deletion server/src/http/consumer_offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::sync::Arc;
pub fn router(state: Arc<AppState>) -> Router {
Router::new()
.route(
"/streams/:stream_id/topics/:topic_id/consumer-offsets",
"/streams/{stream_id}/topics/{topic_id}/consumer-offsets",
get(get_consumer_offset).put(store_consumer_offset),
)
.with_state(state)
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use tracing::instrument;
pub fn router(state: Arc<AppState>) -> Router {
Router::new()
.route(
"/streams/:stream_id/topics/:topic_id/messages",
"/streams/{stream_id}/topics/{topic_id}/messages",
get(poll_messages).post(send_messages),
)
.route(
"/streams/:stream_id/topics/:topic_id/messages/flush/:partition_id/:fsync",
"/streams/{stream_id}/topics/{topic_id}/messages/flush/{partition_id}/{fsync}",
get(flush_unsaved_buffer),
)
.with_state(state)
Expand Down
2 changes: 1 addition & 1 deletion server/src/http/partitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use tracing::instrument;
pub fn router(state: Arc<AppState>) -> Router {
Router::new()
.route(
"/streams/:stream_id/topics/:topic_id/partitions",
"/streams/{stream_id}/topics/{topic_id}/partitions",
post(create_partitions).delete(delete_partitions),
)
.with_state(state)
Expand Down
2 changes: 1 addition & 1 deletion server/src/http/personal_access_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn router(state: Arc<AppState>) -> Router {
get(get_personal_access_tokens).post(create_personal_access_token),
)
.route(
"/personal-access-tokens/:name",
"/personal-access-tokens/{name}",
delete(delete_personal_access_token),
)
.route(
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ pub fn router(state: Arc<AppState>) -> Router {
Router::new()
.route("/streams", get(get_streams).post(create_stream))
.route(
"/streams/:stream_id",
"/streams/{stream_id}",
get(get_stream).put(update_stream).delete(delete_stream),
)
.route("/streams/:stream_id/purge", delete(purge_stream))
.route("/streams/{stream_id}/purge", delete(purge_stream))
.with_state(state)
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/http/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn router(state: Arc<AppState>, metrics_config: &HttpMetricsConfig) -> Route
.route("/ping", get(|| async { PONG }))
.route("/stats", get(get_stats))
.route("/clients", get(get_clients))
.route("/clients/:client_id", get(get_client))
.route("/clients/{client_id}", get(get_client))
.route("/snapshot", post(get_snapshot));
if metrics_config.enabled {
router = router.route(&metrics_config.endpoint, get(get_metrics));
Expand Down
6 changes: 3 additions & 3 deletions server/src/http/topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ use tracing::instrument;
pub fn router(state: Arc<AppState>) -> Router {
Router::new()
.route(
"/streams/:stream_id/topics",
"/streams/{stream_id}/topics",
get(get_topics).post(create_topic),
)
.route(
"/streams/:stream_id/topics/:topic_id",
"/streams/{stream_id}/topics/{topic_id}",
get(get_topic).put(update_topic).delete(delete_topic),
)
.route(
"/streams/:stream_id/topics/:topic_id/purge",
"/streams/{stream_id}/topics/{topic_id}/purge",
delete(purge_topic),
)
.with_state(state)
Expand Down
6 changes: 3 additions & 3 deletions server/src/http/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ pub fn router(state: Arc<AppState>) -> Router {
Router::new()
.route("/users", get(get_users).post(create_user))
.route(
"/users/:user_id",
"/users/{user_id}",
get(get_user).put(update_user).delete(delete_user),
)
.route("/users/:user_id/permissions", put(update_permissions))
.route("/users/:user_id/password", put(change_password))
.route("/users/{user_id}/permissions", put(update_permissions))
.route("/users/{user_id}/password", put(change_password))
.route("/users/login", post(login_user))
.route("/users/logout", delete(logout_user))
.route("/users/refresh-token", post(refresh_token))
Expand Down

0 comments on commit c04acf6

Please sign in to comment.