{"id":23740225,"url":"https://github.com/mustaddon/serviceproviderendpoint","last_synced_at":"2026-04-26T22:31:08.698Z","repository":{"id":62418094,"uuid":"560473461","full_name":"mustaddon/ServiceProviderEndpoint","owner":"mustaddon","description":".NET IServiceProvider webapi endpoint for faster and easier development","archived":false,"fork":false,"pushed_at":"2024-01-12T12:01:54.000Z","size":196,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-26T10:05:21.158Z","etag":null,"topics":["aspnet","aspnetcore","autogenerated-api","csharp","dotnet","endpoint","generic-endpoint","minimal-api","rest-api","service-provider","service-provider-endpoint","serviceprovider","serviceprovider-endpoint","web-api","webapi"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mustaddon.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,"publiccode":null,"codemeta":null}},"created_at":"2022-11-01T15:22:53.000Z","updated_at":"2024-03-05T07:44:14.000Z","dependencies_parsed_at":"2024-01-12T15:46:57.137Z","dependency_job_id":"ce4e6f55-0e01-483b-80f7-bde43a607c11","html_url":"https://github.com/mustaddon/ServiceProviderEndpoint","commit_stats":{"total_commits":41,"total_committers":1,"mean_commits":41.0,"dds":0.0,"last_synced_commit":"68cd9e4c7fb774840b318ffd4c7f921fcdab7f9c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FServiceProviderEndpoint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FServiceProviderEndpoint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FServiceProviderEndpoint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustaddon%2FServiceProviderEndpoint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mustaddon","download_url":"https://codeload.github.com/mustaddon/ServiceProviderEndpoint/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239886550,"owners_count":19713502,"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":["aspnet","aspnetcore","autogenerated-api","csharp","dotnet","endpoint","generic-endpoint","minimal-api","rest-api","service-provider","service-provider-endpoint","serviceprovider","serviceprovider-endpoint","web-api","webapi"],"created_at":"2024-12-31T09:47:30.333Z","updated_at":"2026-03-03T22:30:21.917Z","avatar_url":"https://github.com/mustaddon.png","language":"C#","readme":"# ServiceProviderEndpoint [![NuGet version](https://badge.fury.io/nu/ServiceProviderEndpoint.svg?)](http://badge.fury.io/nu/ServiceProviderEndpoint)\nIServiceProvider webapi endpoint for faster and easier development.\n\n\n## Usage\nIf you have already registered services in the collection and want to give access to them via http, then just map a universal endpoint like this:\n```C#\napp.MapServiceProvider(\"services\", builder.Services);\napp.Run();\n```\n\nNow you can send post/get requests to your services, like:\n```\nGET /services/IYourService/SomeMethod?args=[\"arg1\",\"arg2\",\"arg3\"]\n\nor\n\nPOST /services/IYourService/SomeMethod\nContent-Type: application/json\n[\"arg1\",\"arg2\",\"arg3\"]\n```\n\n\n## Generics\nExample request with generics:\n```\nGET /services/IYourService/SomeGenericMethod(Int32)?args=[111,222,333]\n```\nRequests use URL-safe notation for types. For example, **Dictionary(String-Array(Int32))** is equivalent of **Dictionary\u003cstring,int[]\u003e**. \n\n\n## Type casting\nIf your method has object type arguments like:\n```C#\nTask\u003cint\u003e ExampleMethod(object data, CancellationToken cancellationToken);\n```\nThen you need to add the type for cast as an additional parameter to the request:\n```\nGET /services/IYourService/ExampleMethod/List(String)?args=[[\"list_item1\",\"list_item2\",\"list_item3\"]]\n```\n\n\n## File streams\nFor downloading, it is enough that the method returns a stream object:\n```C#\nTask\u003cStream\u003e SomeDownloadMethod(string a, string b, string c, CancellationToken cancellationToken);\n```\nDownload request will be like this:\n```\nGET /services/IYourService/SomeDownloadMethod?args=[\"argA\",\"argB\",\"argC\"]\n```\n\n\nFor uploading, the method must have an argument of type Stream (position doesn't matter):\n```C#\nTask SomeUploadMethod(Stream stream, string a, string b, string c, CancellationToken cancellationToken); \n```\nUpload request:\n```\nPOST /services/IYourService/SomeUploadMethod?args=[\"argA\",\"argB\",\"argC\"]\nContent-Type: application/octet-stream\n\u003cSomeFileData\u003e\n```\nJavaScript example:\n```js\nlet file = document.getElementById('some-input').files[0];\nlet response = await fetch('/services/IYourService/SomeUploadMethod?args='+encodeURIComponent(JSON.stringify([\"argA\",\"argB\",\"argC\"])), {\n  method: 'POST',\n  headers: { 'content-type': file.type || 'application/octet-stream' },\n  body: file,\n});\n```\n\n## Security\nIf you don't want to publish all services in the collection, then just add a filter:\n```C#\napp.MapServiceProvider(\"services\", builder.Services\n  .Where(x =\u003e x.ServiceType.Namespace.StartsWith(\"Example\")));\n```\n\nIf authorization is needed, then it is added by the standard method for IEndpointConventionBuilder:\n```C#\napp.MapServiceProvider(\"services\", builder.Services)\n  .RequireAuthorization();\n```\n\nSecurity for methods can be added via [Scrutor-decorators](https://github.com/khellang/Scrutor):\n```C#\nbuilder.Services.AddScoped\u003cIExampleService, ExampleService\u003e();\nbuilder.Services.Decorate\u003cIExampleService, SecureExampleService\u003e();\n```\n\n\n## .NET client\nTo connect to api from another .net application, use an existing client:\n```C#\nusing ServiceProviderEndpoint.Client;\n\nusing var client = new SpeClient(\"https://localhost:7149/services\");\n\nvar result = await client\n  .GetService\u003cIYourService\u003e()\n  .SomeMethod(\"arg1\",\"arg2\",\"arg3\");\n```\n\n\n## Example projects\n* [WebApi](https://github.com/mustaddon/ServiceProviderEndpoint/tree/main/Examples/Example.WebApi/Program.cs)\n* [ClientApp](https://github.com/mustaddon/ServiceProviderEndpoint/tree/main/Examples/Example.Client/Program.cs)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustaddon%2Fserviceproviderendpoint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmustaddon%2Fserviceproviderendpoint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustaddon%2Fserviceproviderendpoint/lists"}