Skip to content

Splitting up main.rs into modules#13

Merged
svnoak merged 1 commit intomainfrom
refactor/split-server-into-modules
Jul 7, 2025
Merged

Splitting up main.rs into modules#13
svnoak merged 1 commit intomainfrom
refactor/split-server-into-modules

Conversation

@svnoak
Copy link
Owner

@svnoak svnoak commented Jul 7, 2025

Splitting up main.rs into modules for better maintainability of the project.

@svnoak svnoak requested a review from Copilot July 7, 2025 15:43
Copy link

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

Splits main.rs into dedicated modules for improved structure and maintainability.

  • Extracts WebSocket handling (websocket.rs) and HTTP forwarding (forwarding.rs) into separate files.
  • Introduces a Config loader (config.rs) and a logging setup module (logging.rs).
  • Refactors AppState initialization and moves access control logic into its own module.

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/src/websocket.rs New module for WebSocket upgrade and session handling
server/src/forwarding.rs New module for HTTP request forwarding logic
server/src/models.rs Extracted shared request/response data structures
server/src/config.rs Added Config struct to centralize environment variable loading
server/src/logging.rs Added setup_tracing() for environment-aware logging
server/src/access_control.rs New module for client authentication checks
server/src/main.rs Updated imports, routing setup, and initialization calls
Cargo.toml Enabled JSON output feature for tracing-subscriber
Comments suppressed due to low confidence (2)

server/src/config.rs:13

  • [nitpick] This reads IS_PRODUCTION, but logging.rs checks APP_ENV. Consider unifying on a single environment variable name to avoid confusion.
        let is_production = env::var("IS_PRODUCTION")

server/src/forwarding.rs:16

  • The forwarding logic is critical but has no accompanying tests. Consider adding unit or integration tests for handle_forwarding_request to verify correct behavior.
pub async fn handle_forwarding_request(

break;
}
}
Some(Ok(msg)) = socket.recv() => {
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

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

The Err variant from socket.recv() is silently ignored, exiting the loop without logging. Consider matching Some(Err(e)) to log receive errors.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

Not relevant for this PR

@svnoak svnoak merged commit a41c588 into main Jul 7, 2025
2 checks passed
@svnoak svnoak deleted the refactor/split-server-into-modules branch July 10, 2025 21:30
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