Skip to content

feat: add init command and cleanup config#1

Merged
Akagi201 merged 2 commits intomasterfrom
feature/init-command-and-cleanup
Nov 24, 2025
Merged

feat: add init command and cleanup config#1
Akagi201 merged 2 commits intomasterfrom
feature/init-command-and-cleanup

Conversation

@Akagi201
Copy link
Copy Markdown
Member

@Akagi201 Akagi201 commented Nov 24, 2025

This PR introduces several improvements to the Axon project:

Features

  • New init command: Added axon init to generate a default config.toml file, improving the onboarding experience.

Refactoring & Cleanup

  • Configuration Cleanup: Removed unused acme and http1_enabled fields from ServerConfig in src/config/models.rs.
  • Code Cleanup: Removed dead code in src/adapters/http_handler.rs related to the removed configuration.

Tests & Examples

  • Script Permissions: Fixed execution permissions for all scripts in examples/scripts/.
  • Test Scripts:
    • Split proxy_single.sh into proxy_single.sh (basic proxy) and proxy_single_rewrite.sh (proxy with rewrite) to correctly match the example configurations.
    • Verified all examples pass using examples/scripts/run_all.sh.

All integration tests passed locally.

Summary by CodeRabbit

  • New Features

    • Added an Init CLI command to generate a default configuration file.
  • Refactor

    • Removed HTTP/1.1 configuration flag and ACME automatic TLS provisioning; TLS now requires manual cert/key paths.
    • Removed unused WebSocket proxy stub.
  • Tests / Examples

    • Improved example proxy scripts with a temporary backend server, stricter cleanup, and functional response verification.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 24, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Removes HTTP/1.1 flag and ACME/TLS ACME scaffolding from configuration, deletes a WebSocket proxy stub from the HTTP handler, adds an Init CLI subcommand that writes a default config, and updates/adds example scripts to start a test backend and perform functional /api/hello checks.

Changes

Cohort / File(s) Summary
Example test scripts
examples/scripts/proxy_single.sh, examples/scripts/proxy_single_rewrite.sh
proxy_single.sh updated to reference proxy_single.toml, create a temporary backend dir, run a simple HTTP server serving /api/hello, use functional curl checks validating response content, and ensure cleanup. proxy_single_rewrite.sh added: launches Python HTTP backend on port 9001, starts gateway with config, waits for listeners, performs readiness and dual-endpoint /api and /api/ checks, and traps cleanup.
Configuration models & validation
src/config/models.rs, src/config/validation.rs
Removed http1_enabled from ServerConfig/builder and removed acme: Option<AcmeConfig> plus the AcmeConfig struct; deleted ACME validation paths and InvalidAcme error variant; TLS validation now requires cert and key paths only.
HTTP adapter
src/adapters/http_handler.rs
Removed the placeholder handle_websocket_upgrade async method (previously returned 501 NOT_IMPLEMENTED).
CLI / main
src/main.rs
Added Init { config: String } variant to Commands, added async fn init_config_command(config_path: &str) -> Result<()>, and dispatch logic to create a default config file if not present.

Sequence Diagram(s)

sequenceDiagram
    participant User as User (CLI)
    participant Main as main.rs
    participant Init as init_config_command

    User->>Main: Run "init" command
    Main->>Init: init_config_command(config_path)

    rect rgba(220, 240, 255, 0.3)
    Note over Init: Check for existing file
    Init->>Init: If file exists -> error
    end

    rect rgba(220, 255, 220, 0.3)
    Note over Init: Generate & write
    Init->>Init: Render default config
    Init->>Init: Write file to path
    Init-->>User: Success + guidance
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to any remaining references to http1_enabled or AcmeConfig elsewhere in the codebase (builders, docs, tests).
  • Confirm that removal of handle_websocket_upgrade doesn't leave route handlers or trait impls expecting it.
  • Verify CLI parsing and the default config template in init_config_command for correctness.

Possibly related PRs

Poem

🐰 I dug a dir, I spun a small host,
Wrote configs fresh — I brag the most.
Old websockets shelved, flags left behind,
Init seeds a file for users to find.
Hop, plug, and run — a rabbit-made design.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main changes: adding an 'init' command to the CLI and cleaning up unused configuration fields (acme and http1_enabled).
Docstring Coverage ✅ Passed Docstring coverage is 81.82% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 447641d and f4a8dc9.

📒 Files selected for processing (1)
  • examples/scripts/proxy_single_rewrite.sh (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c9bfef and 447641d.

📒 Files selected for processing (6)
  • examples/scripts/proxy_single.sh (1 hunks)
  • examples/scripts/proxy_single_rewrite.sh (1 hunks)
  • src/adapters/http_handler.rs (0 hunks)
  • src/config/models.rs (1 hunks)
  • src/config/validation.rs (3 hunks)
  • src/main.rs (4 hunks)
💤 Files with no reviewable changes (1)
  • src/adapters/http_handler.rs
🧰 Additional context used
🧬 Code graph analysis (2)
examples/scripts/proxy_single.sh (1)
examples/scripts/_lib.sh (3)
  • cleanup_ports (8-25)
  • wait_port_listen (29-42)
  • timeout_guard (66-70)
examples/scripts/proxy_single_rewrite.sh (1)
examples/scripts/_lib.sh (4)
  • cleanup_ports (8-25)
  • wait_port_listen (29-42)
  • timeout_guard (66-70)
  • wait_http_ok (46-63)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Agent
  • GitHub Check: build-test-examples
🔇 Additional comments (12)
src/config/validation.rs (2)

9-9: LGTM: Import cleanup aligns with ACME removal.

The removal of AcmeConfig from imports is consistent with the PR's goal to remove ACME scaffolding from the codebase.


344-367: LGTM: TLS validation simplified to manual certificates only.

The validation logic correctly enforces that both certificate and private key paths must be provided together. The error message is clear and actionable. This aligns with the removal of ACME support across the codebase.

examples/scripts/proxy_single_rewrite.sh (3)

1-9: LGTM: Script setup follows best practices.

The script correctly uses strict mode (set -euo pipefail) and properly sources the helper library. The configuration references the correct file for this rewrite test scenario.


10-16: LGTM: Backend setup is robust.

The script properly cleans up ports, captures the backend PID, sets up exit traps, and waits for the backend to be listening before proceeding. This ensures reliable test execution.


18-24: LGTM: Gateway startup is properly managed.

The gateway setup includes proper PID tracking, timeout protection, comprehensive trap handling, and functional HTTP readiness verification. This ensures the gateway is actually ready to handle requests before testing begins.

examples/scripts/proxy_single.sh (3)

8-8: LGTM: Config file update aligns with script split.

The change from proxy_single_rewrite.toml to proxy_single.toml correctly reflects the separation of basic proxy testing from rewrite testing, as described in the PR objectives.


12-21: LGTM: Temporary directory approach improves test isolation.

The script now creates an isolated temporary directory with a controlled backend structure. This is a best practice for integration testing as it avoids filesystem dependencies and ensures cleanup. The trap handling properly removes the temporary directory on exit.


30-37: LGTM: Content validation is more robust.

The test now verifies the actual response content rather than just HTTP status codes. The prefix match ("hello from backend"*) appropriately handles potential trailing content from the HTTP server, and the error message provides actionable debugging information.

src/config/models.rs (1)

307-314: LGTM: TLS configuration simplified correctly.

The removal of ACME-related fields and the updated documentation clearly indicate this struct now only supports manual certificate/key pair configuration. The use of Option<String> for both fields is appropriate and consistent with the validation logic that requires both to be present together.

src/main.rs (3)

43-48: LGTM: Init command definition follows established patterns.

The new Init command is well-structured, follows the same pattern as existing commands (Validate and Serve), and provides a sensible default value for the config path. The documentation is clear and concise.


66-66: LGTM: Command dispatch logic is consistent.

The Init command is properly integrated into the command dispatch flow, following the same early-return pattern as the Validate command. This correctly prevents server startup when running the init command.

Also applies to: 75-77


656-701: LGTM: Init command implementation is well-designed.

The init_config_command function follows good practices:

  • Prevents accidental overwrite by checking for existing files
  • Provides a well-structured default configuration with examples
  • Uses async I/O appropriately
  • Includes helpful success messages guiding the user on next steps
  • The default configuration template is comprehensive and includes commented examples for different route types

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new axon init command for improved onboarding and removes unused ACME/HTTP1 configuration fields to simplify the codebase.

  • Adds axon init command to generate a default config.toml file with sensible defaults
  • Removes unused acme and http1_enabled configuration fields from ServerConfig and associated validation logic
  • Removes dead WebSocket handler code that was never referenced
  • Splits proxy test scripts to correctly match their respective configuration files
  • Adds comprehensive helper library (_lib.sh) for test scripts
  • Introduces new WebSocket integration test scripts for various scenarios

Reviewed changes

Copilot reviewed 6 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main.rs Adds new Init command variant and init_config_command function to generate default config files
src/config/models.rs Removes http1_enabled field, AcmeConfig struct, and acme-related builder methods from ServerConfig
src/config/validation.rs Removes InvalidAcme error variant, validate_acme_config function, and simplifies TLS validation logic
src/adapters/http_handler.rs Removes unused handle_websocket_upgrade placeholder method
examples/scripts/_lib.sh Adds shared helper functions for test scripts (port cleanup, waiting, timeout guards)
examples/scripts/proxy_single.sh Updates to test basic proxy scenario without path rewriting
examples/scripts/proxy_single_rewrite.sh New script to test proxy with path rewriting to match proxy_single_rewrite.toml config
examples/scripts/ws_echo.sh Adds WebSocket echo test with subprotocol negotiation
examples/scripts/ws_binary.sh Adds WebSocket binary frame test
examples/scripts/ws_close.sh Adds WebSocket close frame test
examples/scripts/ws_large_payload.sh Adds WebSocket large payload and idle timeout test
examples/scripts/ws_ping_pong.sh Adds WebSocket ping/pong frame test

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Akagi201 Akagi201 merged commit f63a9b3 into master Nov 24, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants