{"id":25419311,"url":"https://github.com/horse-framework/horse-http","last_synced_at":"2025-10-31T10:31:06.381Z","repository":{"id":43858128,"uuid":"279107553","full_name":"horse-framework/horse-http","owner":"horse-framework","description":"Lightweight and fast HTTP Server with MVC Architecture","archived":false,"fork":false,"pushed_at":"2024-06-23T10:08:00.000Z","size":186,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-04T06:35:36.794Z","etag":null,"topics":["http","http-server","mvc-framework"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/horse-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-07-12T16:49:49.000Z","updated_at":"2024-11-17T18:38:31.000Z","dependencies_parsed_at":"2024-02-20T14:43:57.522Z","dependency_job_id":null,"html_url":"https://github.com/horse-framework/horse-http","commit_stats":null,"previous_names":["horse-framework/horse-mvc","twino-framework/twino-mvc"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horse-framework%2Fhorse-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horse-framework%2Fhorse-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horse-framework%2Fhorse-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horse-framework%2Fhorse-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/horse-framework","download_url":"https://codeload.github.com/horse-framework/horse-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238610550,"owners_count":19500674,"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":["http","http-server","mvc-framework"],"created_at":"2025-02-16T18:37:18.257Z","updated_at":"2025-10-31T10:31:06.006Z","avatar_url":"https://github.com/horse-framework.png","language":"C#","readme":"# Horse HTTP\n\n[![NuGet](https://img.shields.io/nuget/v/Horse.Mvc?label=mvc%20nuget)](https://www.nuget.org/packages/Horse.Mvc)\n[![NuGet](https://img.shields.io/nuget/v/Horse.Mvc.Auth.Jwt?label=jwt%20extension%20nuget)](https://www.nuget.org/packages/Horse.Mvc.Auth.Jwt)\n[![NuGet](https://img.shields.io/nuget/v/Horse.Protocols.Http?label=http%20server%20nuget)](https://www.nuget.org/packages/Horse.Protocols.Http)\n\nHorse HTTP is an HTTP Server implementation of Horse Server. Horse MVC is MVC architecture layer of http server. It's usage is very similar to ASP.NET Core and faster. You can also ise core Protocols. Http library for basic HTTP server without MVC.\n\n\n### Basic Example\n\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            HorseMvc mvc = new HorseMvc();\n            mvc.Init(m =\u003e\n            {\n                //initialization\n                m.Services.AddTransient\u003cISampleService, SampleService\u003e();\n            });\n            mvc.Use(app =\u003e\n            {\n                app.UseMiddleware\u003cSampleMiddleware\u003e();\n            });\n\n            //create new twino server\n            HorseServer server = new HorseServer();\n            \n            //bind MVC to the server\n            server.UseMvc(mvc, HttpOptions.CreateDefault());\n            \n            //start server\n            server.Run();\n        }\n    }\n\n    [Route(\"[controller]\")]\n    public class DemoController : HorseController\n    {\n        [HttpGet(\"get/{?id}\")]\n        public Task\u003cIActionResult\u003e Get([FromRoute] int? id)\n        {\n            return StringAsync(\"Hello world: \" + id);\n        }\n\n        [HttpPost(\"get2\")]\n        public async Task\u003cIActionResult\u003e Get2([FromBody] CustomModel model)\n        {\n            return await JsonAsync(new {Message = \"Hello World Json\"});\n        }\n    }\n\n\n### JWT Example\n\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            HorseMvc mvc = new HorseMvc();\n            mvc.Init(m =\u003e\n            {\n                //initialization\n                mvc.AddJwt(o =\u003e\n                {\n                    o.Audience = \"your_company\";\n                    o.Issuer = \"yoursite.com\";\n                    o.ValidateAudience = false;\n                    o.ValidateIssuer = true;\n                    o.ValidateLifetime = true;\n                    o.Key = \"your_secret\";\n                    o.Lifetime = TimeSpan.FromHours(1);\n                });\n            });\n            \n            mvc.Use(app =\u003e\n            {\n                app.UseMiddleware(cors);\n            });\n\n            //create new horse server\n            HorseServer server = new HorseServer();\n            \n            //bind MVC to the server\n            server.UseMvc(mvc, HttpOptions.CreateDefault());\n            \n            //start server\n            server.Run();\n        }\n    }\n    \n    [Route(\"[controller]\")]\n    public class DemoController : HorseController\n    {\n        [HttpGet]\n        [Authorize]\n        public Task\u003cIActionResult\u003e Get()\n        {\n            //you can use User property of HorseController\n            \n            return StringAsync(\"Hello, World!\");\n        }\n    }\n\n\n### CORS and Some Useful Options\n\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            HorseMvc mvc = new HorseMvc();\n            \n            mvc.Init();\n            \n            //create cors service and allow all (not related to jwt)\n            CorsMiddleware cors = new CorsMiddleware();\n            cors.AllowAll();\n            \n            mvc.Use(app =\u003e\n            {\n                app.UseMiddleware(cors);\n            });\n\n            //use global result for internal errors\n            mvc.StatusCodeResults.Add(HttpStatusCode.InternalServerError, new JsonResult(new SampleResult {Ok = false, Code = \"Error\"}));\n            \n            //use global result for unauthorized results\n            mvc.StatusCodeResults.Add(HttpStatusCode.Unauthorized, new JsonResult(new SampleResult {Ok = false, Code = \"Unauthorized\"}));\n\n            //use custom handler for errors (CustomErrorHandler implements IErrorHandler)\n            mvc.ErrorHandler = new CustomErrorHandler();\n            \n            //create new twino server\n            HorseServer server = new HorseServer();\n            \n            //bind MVC to the server\n            server.UseMvc(mvc, HttpOptions.CreateDefault());\n            \n            //start server\n            server.Run();\n        }\n    }\n\n\n## Thanks\n\nThanks to JetBrains for open source license to use on this project.\n\n[![jetbrains](https://user-images.githubusercontent.com/21208762/90192662-10043700-ddcc-11ea-9533-c43b99801d56.png)](https://www.jetbrains.com/?from=twino-framework)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorse-framework%2Fhorse-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhorse-framework%2Fhorse-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorse-framework%2Fhorse-http/lists"}