{"id":17181076,"url":"https://github.com/fawdlstty/sparrow","last_synced_at":"2025-04-13T17:22:05.682Z","repository":{"id":38056057,"uuid":"200010575","full_name":"fawdlstty/Sparrow","owner":"fawdlstty","description":"此项目是一个精简的Web实现示例，通过反射机制实现rpc、websocket、swagger及monitor","archived":false,"fork":false,"pushed_at":"2022-11-10T10:13:03.000Z","size":2666,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T08:11:23.750Z","etag":null,"topics":["http-server","rest-api","rest-rpc","swagger","websocket","websocket-server"],"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/fawdlstty.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}},"created_at":"2019-08-01T08:31:43.000Z","updated_at":"2022-11-21T20:38:14.000Z","dependencies_parsed_at":"2022-08-18T13:20:17.953Z","dependency_job_id":null,"html_url":"https://github.com/fawdlstty/Sparrow","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/fawdlstty%2FSparrow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fawdlstty%2FSparrow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fawdlstty%2FSparrow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fawdlstty%2FSparrow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fawdlstty","download_url":"https://codeload.github.com/fawdlstty/Sparrow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248750855,"owners_count":21155795,"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-server","rest-api","rest-rpc","swagger","websocket","websocket-server"],"created_at":"2024-10-15T00:32:52.538Z","updated_at":"2025-04-13T17:22:05.662Z","avatar_url":"https://github.com/fawdlstty.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sparrow\n\n## Description / 描述\n\nSparrow = Minimal for **[Kestrel + WebSocket + Doc + Monitor]**\n\nSparrow is a C# HTTP/REST/RPC/WebSocket Network Library, it can be very easy to act as an HTTP server or heterogeneous RPC service provider, Suitable for single server development (consider adding a master-slave later to ensure 100% availability of the service), the name is from \"麻雀虽小，五脏俱全\".\n\nSparrow（麻雀）是一个C#的 HTTP/REST/RPC/WebSocket 网络库，可以非常容易的作为HTTP服务器或异构RPC服务提供者，适合用于开发单机型服务器（后期考虑加入主从，用来保证服务的100%可用性），名称源于“麻雀虽小，五脏俱全”。\n\nUsage / 用法：\n\n```csharp\nusing SparrowServer;\nusing SparrowServer.Attributes;\nusing System;\nusing System.Threading.Tasks;\n\nnamespace TestServer {\n    [HTTPModule (\"hello world模块\")]\n    public class HelloModule {\n        [HTTP (\"Test Hello World\")]\n        public static string test_hello () {\n            return \"hello world\";\n        }\n    }\n}\n```\n\nSparrow searches for all possible Web services in a module and passes the specified module assembly when the document is generated.Co-provision of Web services in multiple assemblies is not currently supported (considering that large projects can be time-consuming).The main service function is as follows:\n\nSparrow会在模块中搜索所有可能的Web服务，生成文档时需要传递指定的模块assembly。暂不支持多个assembly中共同提供Web服务（考虑到大型项目可能比较耗时）。服务主函数如下：\n\n```csharp\nstatic void Main (string [] args) {\n    FawHttpServer _sss = new FawHttpServer (1234, Assembly.GetExecutingAssembly (), Guid.NewGuid ().ToString (\"N\"));\n    // Without calling this interface, the swagger document is not generated\n    // 如果没有调用这个接口，将不会生成swagger文档\n    _sss.set_doc_info (new WEBDocInfo {\n        DocName = \"Test interface documentation\",\n        Version = \"0.0.1\",\n        Description = \"This is a large document, and I have omitted 10,000 words here\",\n        Contact = \"f@fawdlstty.com\",\n        Scheme = \"http\",\n        Host = \"127.0.0.1:1234\"\n    });\n    // enable monitor (current not implement)\n    // 启用状态监控（暂时无用）\n    _sss.enable_monitor ();\n    // If this function is called, the HTTPS protocol is provided externally, otherwise the HTTP protocol is provided\n    // 如果调用了这个函数，那么将对外提供https协议，否则提供http协议\n    _sss.set_ssl_file (\"F:/test.pfx\", \"12345678\");\n    _sss.run ();\n}\n```\n\nAt this time will be automatically generated rest RPC interface, request \u003chttp://127.0.0.1:1234/api/Hello/test_hello\u003e will invoke this method, return to the content of: `{ \"result\":\"success\",\"content\":\"hello world\"}`\n\n此时将会自动生成rest rpc接口，请求\u003chttp://127.0.0.1:1234/api/Hello/test_hello\u003e将调用此方法，返回内容为：`{ \"result\":\"success\",\"content\":\"hello world\"}`\n\nRun the project at this point and the document will be generated automatically. The document address is \u003chttp://127.0.0.1:1234/swagger/index.html\u003e.\n\n此时运行项目，文档将会自动生成，文档地址位于\u003chttp://127.0.0.1:1234/swagger/index.html\u003e。\n\n## Document / 文档\n\n[English document](./doc/en-us.md)\n\n[中文文档](./doc/zh-cn.md)\n\n## Reference / 引用\n\n\u003chttps://github.com/swagger-api/swagger-ui\u003e\n\n\u003chttps://github.com/JamesNK/Newtonsoft.Json\u003e\n\n\u003chttps://github.com/jwt-dotnet/jwt\u003e\n\n## TODO / 待完善\n\ncookie\n\nHTTP客户端、代理（正向、反向、匿名，受控）\n\n数据检查\n\n监控流量\n\n主机及程序运行监视页面（暂时考虑grafana）\n\n双机/三机主从（分布式，保证服务100%可用性）\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffawdlstty%2Fsparrow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffawdlstty%2Fsparrow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffawdlstty%2Fsparrow/lists"}