Skip to content

Чтение всех параметров конфигурации Kestrel из appsettings.json #1521

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

Merged
merged 1 commit into from
Mar 13, 2025

Conversation

Stivo182
Copy link
Contributor

@Stivo182 Stivo182 commented Mar 11, 2025

Closes #1519

Раннее настройки из appsettings.json читались, но некоторые настройки (в т.ч. раздел Kestrel.Limits) не применялись для Kestrel. Данным PR эта проблема решается.

Более подробно эта проблема обсуждалась в этом треде. А решение было написано в комментарии.

Summary by CodeRabbit

  • New Features
    • Enhanced the web server’s configuration capability by enabling dynamic loading and binding of settings from the application’s configuration file. This results in greater flexibility and streamlined updates to server behavior during deployments, ensuring a smoother, more responsive operational experience. The improvement also streamlines administration by permitting configuration adjustments without altering code, supporting evolving requirements and simplifying maintenance across diverse environments.

Copy link

coderabbitai bot commented Mar 11, 2025

Walkthrough

This change enhances the configuration of the Kestrel web server by introducing code that reads the "Kestrel" section from the application's configuration. Inside the ConfigureKestrel method, the new code retrieves configuration settings, applies them using options.Configure(), and binds them directly to the server options with kestrelSection.Bind(options). This update allows for dynamic server configuration via configuration files.

Changes

File Path Change Summary
src/OneScript.Web.Server/WebServer.cs Added using directive for Microsoft.Extensions.Configuration; modified the ConfigureKestrel method to retrieve the "Kestrel" configuration section, apply it via options.Configure(), and bind it to options with kestrelSection.Bind(options).

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant WS as WebServer
    participant Config as Configuration

    App->>WS: Invoke ConfigureApp/ConfigureKestrel
    WS->>Config: Retrieve "Kestrel" section
    Config-->>WS: Return configuration values
    WS->>WS: Apply configuration via options.Configure()
    WS->>WS: Bind values with kestrelSection.Bind(options)
Loading

Poem

Oh, what a hop in our code today,
The Kestrel leaps in a configurable way.
With settings bound so neat and clear,
A rabbit's delight brings joyful cheer.
Hopping through configs with a skip and a smile! 🐇✨
Bound to new paths, we code in style!


📜 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 dbaac06 and 410dd91.

📒 Files selected for processing (1)
  • src/OneScript.Web.Server/WebServer.cs (2 hunks)
🔇 Additional comments (2)
src/OneScript.Web.Server/WebServer.cs (2)

19-19: Good addition of the required namespace.

Adding the Microsoft.Extensions.Configuration namespace is necessary to access the configuration functionality that's used in the Kestrel configuration code.


95-98: Excellent implementation for reading Kestrel configuration.

This implementation correctly addresses the issue where Kestrel.Limits wasn't being applied despite being in appsettings.json. The approach uses both:

  1. options.Configure(kestrelSection) - Applies Kestrel-specific configuration (endpoints, certificates, etc.)
  2. kestrelSection.Bind(options) - Ensures all configuration values (including limits) are bound to the options

This comprehensive approach ensures all Kestrel configuration parameters, including the Limits section, will be properly read and applied from appsettings.json.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@EvilBeaver EvilBeaver merged commit 8e52c5f into EvilBeaver:develop Mar 13, 2025
1 of 2 checks passed
@Stivo182 Stivo182 deleted the feature/load-kestrel-config branch March 17, 2025 22:11
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.

Указание максимального допустимого размера тела запроса для Kestrel
2 participants