{"id":17318706,"url":"https://github.com/oolunar/hypersharp","last_synced_at":"2025-04-14T15:23:03.438Z","repository":{"id":179693136,"uuid":"663984074","full_name":"OoLunar/HyperSharp","owner":"OoLunar","description":"A C# implementation of the HTTP 1.1 protocol.","archived":false,"fork":false,"pushed_at":"2025-03-26T09:31:10.000Z","size":1161,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T14:10:13.247Z","etag":null,"topics":["csharp","csharp-http","dotnet","http","http-handling","http-library","http-protocol","http-routing","http-server","http-server-library","middleware","net8","networking","rest-api","server","web-server"],"latest_commit_sha":null,"homepage":"https://oolunar.github.io/HyperSharp/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OoLunar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"OoLunar","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-07-08T15:51:48.000Z","updated_at":"2025-03-26T09:31:13.000Z","dependencies_parsed_at":"2024-06-28T00:09:59.524Z","dependency_job_id":"a311b97f-c301-44ad-8027-ef5c66c0528b","html_url":"https://github.com/OoLunar/HyperSharp","commit_stats":null,"previous_names":["oolunar/hypersharp"],"tags_count":3,"template":false,"template_full_name":"OoLunar/DSharpPlus.Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoLunar%2FHyperSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoLunar%2FHyperSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoLunar%2FHyperSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoLunar%2FHyperSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OoLunar","download_url":"https://codeload.github.com/OoLunar/HyperSharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248904790,"owners_count":21180855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","csharp-http","dotnet","http","http-handling","http-library","http-protocol","http-routing","http-server","http-server-library","middleware","net8","networking","rest-api","server","web-server"],"created_at":"2024-10-15T13:20:46.429Z","updated_at":"2025-04-14T15:23:03.410Z","avatar_url":"https://github.com/OoLunar.png","language":"C#","funding_links":["https://patreon.com/OoLunar"],"categories":[],"sub_categories":[],"readme":"# HyperSharp Overview\nHyperSharp is a C# implementation of the [HTTP 1.1 protocol](https://www.rfc-editor.org/rfc/rfc9110). It's designed with emphasis on speed, lightweight nature, and most importantly: user-friendliness.\n\nTo get started, you can install the [NuGet package](https://www.nuget.org/packages/HyperSharp/) and follow the [setup](#setup) instructions.\n\nTo request support, you may open up a new GitHub issue, discussion or join the [Discord](https://discord.gg/HvMgJkzs6J).\n\nTo report bugs or request new features, please use GitHub issues.\n\nLastly, all API documentation and tutorials are available on the [website](https://oolunar.github.io/HyperSharp/), which is generated from the latest commit at the [docs](https://github.com/OoLunar/HyperSharp/tree/master/docs) folder.\n\n# Table of Contents\n - [Core Concept: Responders](#core-concept-responders)\n - [Response Handling](#response-handling)\n - [Setup](#setup)\n - [Example: Hello World](#example-hello-world)\n\n# Core Concept: Responders\n\n - The foundation of HyperSharp relies on the concept of responders.\n - A responder consists of a list of delegates.\n - Each delegate is a function that takes a request and produces a response.\n - Both request and response are generic types, allowing customization.\n - All responders and responder dependencies are executed sequentially.\n - If any delegate returns an error or value, all subsequent delegates are skipped and the response is returned.\n\n# Response Handling\n\n - Responders use results and errors for handling responses.\n - Synchronous (`void`) and asynchronous (`Task`/`ValueTask`) execution modes are supported, with no additional setup required from the user.\n\n# Setup\n\nThere are two ways to setup HyperSharp, depending on your needs. The recommended way is to use dependency injection, through `IServiceCollection`:\n\n```csharp\nserviceCollection.AddHyperSharp((serviceProvider, hyperConfiguration) =\u003e\n{\n    IConfiguration configuration = serviceProvider.GetRequiredService\u003cIConfiguration\u003e();\n    string? host = configuration.GetValue(\"server:address\", \"localhost\")?.Trim();\n    if (!IPAddress.TryParse(host, out IPAddress? address))\n    {\n        IPAddress[] addresses = Dns.GetHostAddresses(host);\n        address = addresses.Length != 0 ? addresses[0] : throw new InvalidOperationException(\"The server address could not be resolved to an IP address.\");\n    }\n\n    hyperConfiguration.ListeningEndpoint = new IPEndPoint(address, configuration.GetValue(\"server:port\", 8080));\n    hyperConfiguration.AddResponders(new[] { typeof(HelloWorldResponder) });\n});\n\nIServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();\nHyperServer hyperServer = serviceProvider.GetRequiredService\u003cHyperServer\u003e();\nhyperServer.Start();\n```\n\nWe recommend using the service collection method because the responders use dependency injection to resolve their dependencies. This allows for a more modular and testable design.\n\nHowever, we understand that not everyone wants to use dependency injection. If you don't want to use dependency injection, you can use the `HyperServer` class directly:\n\n```csharp\nHyperServer hyperServer = new(new HyperConfiguration(new HyperConfigurationBuilder()\n{\n    ListeningEndpoint = new IPEndPoint(IPAddress.Loopback, 8080),\n    Responders = new[] { typeof(HelloWorldResponder) }\n}));\n\nhyperServer.Start();\n```\n\n# Example: Hello World\n\n```csharp\nusing System;\nusing System.Threading;\nusing HyperSharp.Protocol;\nusing HyperSharp.Responders;\nusing HyperSharp.Results;\n\npublic class HelloWorldResponder : IResponder\u003cHyperContext, HyperStatus\u003e\n{\n    // Specifies any required types for this responder (empty in this case)\n    public static Type[] Needs =\u003e Type.EmptyTypes;\n\n    // Generates a response indicating success with a message \"Hello World!\"\n    public Result\u003cHyperStatus\u003e Respond(HyperContext context, CancellationToken cancellationToken = default) =\u003e Result.Success(HyperStatus.OK(\"Hello World!\"));\n}\n```\n\nThis example demonstrates the structure of a responder using HyperSharp to create a \"Hello World!\" response.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foolunar%2Fhypersharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foolunar%2Fhypersharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foolunar%2Fhypersharp/lists"}