Skip to content

feat: Introduce Relic web sever - #3

Merged
SandPod merged 1 commit into
serverpod:mainfrom
klkucaj:copy-relic-from-serverpod-repo
Dec 13, 2024
Merged

SandPod merged 1 commit into
serverpod:mainfrom
klkucaj:copy-relic-from-serverpod-repo

Conversation

@klkucaj

@klkucaj klkucaj commented Dec 13, 2024 •

Copy link
Copy Markdown
Contributor

This PR introduces Relic, a lightweight and strictly typed HTTP server.
Inspired by Shelf, Relic focuses on type safety, performance, and modularity while maintaining extensibility.

Key Features

Core Library (lib/)

  • relic.dart:

    • The primary entry point of the library, exposing the core server functionalities.
  • lib/src/:
    This directory organizes the core logic into specialized modules to ensure clarity, scalability, and maintainability.

    • Core Server Files:

      • relic_server.dart: Implements the primary server functionality backed by Dart's HttpServer, handling connections, routing, and core features.
      • relic_server_serve.dart: Provides functionality for serving HTTP requests, with support for advanced features like request hijacking.
    • Modules:

      • handler/: Implements mechanisms for flexible request routing, delegation, and pipelines for chaining handlers.
      • middleware/: Contains utilities to integrate middleware, including extensions and logging functionality for monitoring requests and responses.
      • logger/: Provides structured logging for better observability and debugging.
      • util/: Shared utility functions for common operations within the library.
      • body/: Handles parsing, validation, and type-checking of request/response bodies.
      • message/: Manages HTTP message formatting, including request.dart and response.dart for processing requests and responses.
      • headers/:
        The headers module is a central component of the Relic library, offering robust functionality for handling HTTP headers:
        • Core Functionality:
          • headers.dart: Provides the main abstraction for managing HTTP headers, integrating with various submodules.
          • extension/: Adds utility methods for working with headers represented as strings, enabling ease of use and flexibility.
        • Parsing:
          • parser/: Includes headers_parser.dart and common_types_parser.dart to convert raw headers into structured, validated formats.
        • Type-Safe Headers:
          • typed/: Offers predefined and user-defined typed headers, improving reliability and ensuring correctness.
        • Custom Headers:
          • custom/: Allows for the definition and management of application-specific headers.
        • Error Handling:
          • exception/: Defines error types for invalid or improperly formatted headers, ensuring reliability.
      • static/: Implements the logic for serving static files, including custom directory listings and optimizations for asset handling.
      • hijack/: Provides request hijacking for advanced use cases requiring low-level control.
      • method/: Manages and validates HTTP methods, ensuring adherence to standard protocols.

Test Suite (test/)

The test/ directory includes a comprehensive set of unit and integration tests that validate Relic's features and reliability.

  • Core Test Files:

    • relic_server_test.dart: Tests the primary server's functionality, including routing and connection handling.
    • relic_server_serve_test.dart: Focuses on validating the server's serve logic and advanced features like request hijacking.
  • Subdirectories:

    • handler/: Verifies the routing, delegation, and pipeline mechanisms.
    • middleware/: Tests middleware integration, extensions, and logging functionality.
    • util/: Tests utility functions for correctness and performance.
    • message/: Focuses on request and response message formatting and parsing.
    • headers/:
      • Validates all aspects of the headers/ module, including:
        • Parsing and validation of standard and custom headers.
        • Error handling for malformed or invalid headers.
        • Typed headers and extensions.
    • static/: Ensures proper handling of static file serving and directory listings.
    • hijack/: Tests advanced request hijacking logic for robustness.

Related: #2008

This PR was first opened as serverpod/serverpod#2744 in the Serverpod repository. It was later decided to move the project into its own standalone repository, resulting in the creation of this PR.

@klkucaj klkucaj changed the title Copy relic package from serverpod repository New version of the Relic webserver - adopted from Shelf Dec 13, 2024
@klkucaj
klkucaj force-pushed the copy-relic-from-serverpod-repo branch from 22da813 to 26f38ba Compare December 13, 2024 14:14
@klkucaj klkucaj changed the title New version of the Relic webserver - adopted from Shelf feat: Introduce Relic web sever Dec 13, 2024

@SandPod SandPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

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