Skip to content

Conversation

@carldebilly
Copy link
Owner

@carldebilly carldebilly commented Sep 5, 2025

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

  • 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.

@carldebilly carldebilly requested a review from Copilot September 5, 2025 14:10

This comment was marked as outdated.

- 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.
@carldebilly carldebilly force-pushed the dev/di-supported-config branch from 1a32155 to 127bdf8 Compare September 5, 2025 14:32
@carldebilly carldebilly requested a review from Copilot September 5, 2025 14:33
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

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 ServerOptions class for configurable server settings including port, hostname, and bind addresses
  • Introduced DI extension methods for easy Server registration with service collections
  • Refactored Server constructors to support both direct ServerOptions and IOptions<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.

Comment on lines +47 to 52
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; }
}

Copy link

Copilot AI Sep 5, 2025

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)

Suggested change
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)
{

Copilot uses AI. Check for mistakes.
@carldebilly carldebilly merged commit b34c326 into master Sep 5, 2025
2 checks passed
@carldebilly carldebilly deleted the dev/di-supported-config branch September 5, 2025 14:34
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.

Allow more configuration to be provided for the Server & Listener

2 participants