{"id":20366888,"url":"https://github.com/distantcam/csharp-httprequest-template","last_synced_at":"2025-04-12T05:11:52.537Z","repository":{"id":47463785,"uuid":"162554311","full_name":"distantcam/csharp-httprequest-template","owner":"distantcam","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-15T13:27:30.000Z","size":10,"stargazers_count":9,"open_issues_count":2,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T00:41:26.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/distantcam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-20T09:08:42.000Z","updated_at":"2024-10-26T23:43:50.000Z","dependencies_parsed_at":"2023-01-29T03:05:12.072Z","dependency_job_id":null,"html_url":"https://github.com/distantcam/csharp-httprequest-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distantcam%2Fcsharp-httprequest-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distantcam%2Fcsharp-httprequest-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distantcam%2Fcsharp-httprequest-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distantcam%2Fcsharp-httprequest-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/distantcam","download_url":"https://codeload.github.com/distantcam/csharp-httprequest-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519545,"owners_count":21117761,"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":[],"created_at":"2024-11-15T00:27:37.981Z","updated_at":"2025-04-12T05:11:52.516Z","avatar_url":"https://github.com/distantcam.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenFaaS C# HTTP Template\n\nThis repository contains the template for OpenFaaS using the upgraded `of-watchdog` which allows for higher throughput.\n\n```\n$ faas template store pull csharp-httprequest\n$ faas new --list\nLanguages available as templates:\n- csharp-httprequest\n```\n\nThis template uses a middleware handler in an ASPNET Core Web API. This allows additional context available in the request (by providing the full body to the handler) and more control over the response by passing it back to the HTTP reponse context.\n\n## Using the template\nFirst, pull the template with the faas CLI and create a new function:\n\n```\n$ faas template store pull csharp-httprequest\n$ faas-cli new --lang csharp-httprequest \u003cfunction name\u003e\n```\n\nIn the directory that was created, using the name of you function, you'll find `FunctionHandler.cs`. It will look like this:\n\n``` csharp\nusing Microsoft.AspNetCore.Http;\nusing System.IO;\nusing System.Threading.Tasks;\n\nnamespace Function\n{\n    public class FunctionHandler\n    {\n        public async Task\u003c(int, string)\u003e Handle(HttpRequest request)\n        {\n            var reader = new StreamReader(request.Body);\n            var input = await reader.ReadToEndAsync();\n\n            return (200, $\"Hello! Your input was {input}\");\n        }\n    }\n}\n```\n\nThis is a simple implementation of a hello-world function. \n\nYou are able to add packages to your function using the `dotnet add package` syntax. The packages will be added to your final function's container automatically.\n\nFor example, you could add the popular `Newtonsoft.JSON` package for formatting JSON objects.\n\n```csharp\nusing Microsoft.AspNetCore.Http;\nusing System.Threading.Tasks;\nusing Newtonsoft.Json;\n\nnamespace Function\n{\n    public class SampleResponse\n    {\n        public string FunctionStatus { get; set; }\n    }\n    \n    public class FunctionHandler\n    {\n        public Task\u003c(int, string)\u003e Handle(HttpRequest request)\n        {\n            var res = new SampleResponse();\n            res.FunctionStatus = \"Success\";\n\n            var output = JsonConvert.SerializeObject(res);\n\n            return Task.FromResult((200, output));\n        }\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistantcam%2Fcsharp-httprequest-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdistantcam%2Fcsharp-httprequest-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistantcam%2Fcsharp-httprequest-template/lists"}