-
Notifications
You must be signed in to change notification settings - Fork 1
Introduce DI support and customizable server options #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Added dependency injection extensions for `Server` registration. - Introduced `ServerOptions` for configurable server settings (port, hostname, bind address). - Refactored `Server` constructors to support `ServerOptions`. - Updated tests to validate DI and `ServerOptions` functionality. - Simplified namespace declarations with file-scoped syntax.
1a32155 to
127bdf8
Compare
There was a problem hiding this 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 dependency injection support and configurable server options to the Yllibed.HttpServer project, making it more suitable for modern .NET applications with DI containers.
Key changes include:
- Added
ServerOptionsclass for configurable server settings including port, hostname, and bind addresses - Introduced DI extension methods for easy
Serverregistration with service collections - Refactored
Serverconstructors to support both directServerOptionsandIOptions<ServerOptions>patterns
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Yllibed.HttpServer/Yllibed.HttpServer.csproj | Added PolySharp package reference and InternalsVisibleTo attribute |
| Yllibed.HttpServer/ServerOptions.cs | New configuration class with port, bind addresses, and hostname settings |
| Yllibed.HttpServer/Server.cs | Refactored constructors to support ServerOptions and added DI-friendly constructor |
| Yllibed.HttpServer/Extensions/ServiceCollectionExtensions.cs | New DI extension methods for server registration |
| Yllibed.HttpServer/Server.HttpServerRequest.cs | Minor cleanup removing unused field |
| Multiple test files | Added comprehensive tests for DI scenarios and ServerOptions functionality |
| Documentation files | Updated README with extensive DI and configuration examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| private sealed class MyJsonHandler : JsonHandlerBase<MyResultPayload> | ||
| { | ||
| public MyJsonHandler(string method, string path) : base(method, path) | ||
| { | ||
| public string? A { get; set; } | ||
| public string? B { get; set; } | ||
| } | ||
|
|
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The constructor change from primary constructor syntax to explicit constructor appears to be a regression. Consider keeping the more concise primary constructor syntax: private sealed class MyJsonHandler(string method, string path) : JsonHandlerBase<MyResultPayload>(method, path)
| private sealed class MyJsonHandler : JsonHandlerBase<MyResultPayload> | |
| { | |
| public MyJsonHandler(string method, string path) : base(method, path) | |
| { | |
| public string? A { get; set; } | |
| public string? B { get; set; } | |
| } | |
| private sealed class MyJsonHandler(string method, string path) : JsonHandlerBase<MyResultPayload>(method, path) | |
| { |
This PR introduces dependency injection support and configurable server options to the Yllibed.HttpServer project. The changes make the server more flexible and suitable for modern .NET applications with DI containers.
Closes #6
Serverregistration.ServerOptionsfor configurable server settings (port, hostname, bind address).Serverconstructors to supportServerOptions.ServerOptionsfunctionality.