{"id":16242194,"url":"https://github.com/beetlex-io/httpclients","last_synced_at":"2025-03-19T17:31:24.680Z","repository":{"id":38074993,"uuid":"194517860","full_name":"beetlex-io/HttpClients","owner":"beetlex-io","description":"BeetleX http/websocket client support ssl","archived":false,"fork":false,"pushed_at":"2022-12-08T05:46:18.000Z","size":160,"stargazers_count":35,"open_issues_count":7,"forks_count":11,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-10-13T22:36:06.715Z","etag":null,"topics":["beetlex-http","httpclients","https-client","tls","websocket","websocket-clients"],"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/beetlex-io.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-06-30T13:15:27.000Z","updated_at":"2024-07-30T07:58:45.000Z","dependencies_parsed_at":"2023-01-24T16:15:55.399Z","dependency_job_id":null,"html_url":"https://github.com/beetlex-io/HttpClients","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beetlex-io%2FHttpClients","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beetlex-io%2FHttpClients/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beetlex-io%2FHttpClients/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beetlex-io%2FHttpClients/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beetlex-io","download_url":"https://codeload.github.com/beetlex-io/HttpClients/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221729441,"owners_count":16871022,"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":["beetlex-http","httpclients","https-client","tls","websocket","websocket-clients"],"created_at":"2024-10-10T14:09:56.668Z","updated_at":"2024-10-27T20:26:50.517Z","avatar_url":"https://github.com/beetlex-io.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HttpClients\nBeetleX http and websocket clients for .net standard2.0\n## Install\n```\nInstall-Package BeetleX.Http.Clients -Version 1.6\n```\n``` csharp\n            var result = await \"https://www.baidu.com/\"\n                    .FormUrlRequest()\n                    .Get();\n            Console.WriteLine(result.Body);\n\n            result = await \"https://httpbin.org/get\"\n                     .FormUrlRequest()\n                     .Get();\n            Console.WriteLine(result.Body);\n\n\n            result = await \"https://httpbin.org/post\"\n                     .JsonRequest()\n                     .SetBody(DateTime.Now)\n                     .Post();\n            JToken rdata = result.GetResult\u003cJToken\u003e()[\"data\"];\n\n            Console.WriteLine(rdata);\n\n\n            var buffer = await \"https://httpbin.org/image\"\n                           .BinaryRequest()\n                           .Download();\n\n             result = await \"http://localhost/Upload\"\n                           .FormDataRequest()\n                           .Upload(\"g:\\\\extension_1_4_3_0.rar\", \"g:\\\\extension_1_4_3_0_1.rar\");\n```\n\n### Http Cluster\n``` csharp\nHttpCluster httpCluster = new HttpCluster();\nhttpCluster.DefaultNode\n.Add(\"http://192.168.2.25:8080\")\n.Add(\"http://192.168.2.26:8080\");\nvar client = httpCluster.JsonRequest(\"/customers?count=10\");\nvar data = await client.Get();\nclient = httpCluster.JsonRequest(\"/orders?size=10\");\ndata = await client.Get();\n```\n### Http Cluster interface\n``` csharp\n    public interface INorthWind\n    {\n        Task\u003cEmployee\u003e GetEmployee(int id);\n        [Post]\n        Task\u003cEmployee\u003e Add(Employee emp);\n        [Post]\n        Task\u003cbool\u003e Login(string name, string value);       \n        [Post]\n        Task\u003cEmployee\u003e Modify([CQuery]int id, Employee body);\n    }\n```\n``` csharp\nHttpCluster httpClusterApi = new HttpClusterApi();\nhttpCluster.DefaultNode.Add(\"http://localhost:8080\");\nnorthWind = httpCluster.Create\u003cINorthWind\u003e();\nvar result = await northWind.GetEmployee(1);\n```\n### Multi server\n``` csharp\nhttpCluster.DefaultNode\n    .Add(\"http://192.168.2.25:8080\")\n    .Add(\"http://192.168.2.26:8080\");\n```\n### Server weight\n``` csharp\n.Add(\"http://192.168.2.25:8080\",10)\n.Add(\"http://192.168.2.26:8080\",10);\n.Add(\"http://192.168.2.27:8080\",5);\n```\n### Multi url route\n```\nhttpClusterApi.GetUrlNode(\"/order.*\")\n    .Add(\"http://192.168.2.25:8080\")\n    .Add(\"http://192.168.2.26:8080\");\nhttpClusterApi.GetUrlNode(\"/employee.*\")\n    .Add(\"http://192.168.2.27:8080\")\n    .Add(\"http://192.168.2.28:8080\");\n```\n### github auth sample\n``` csharp\n    [FormUrlFormater]\n    [Host(\"https://github.com\")]\n    public interface IGithubAuth\n    {\n\n        [Get(Route = \"login/oauth/access_token\")]\n        Task\u003cstring\u003e GetToken(string client_id, string client_secret, string code);\n\n        [Host(\"https://api.github.com\")]\n        [CHeader(\"User-Agent\", \"beetlex.io\")]\n        [Get(Route = \"user\")]\n        Task\u003cstring\u003e GetUser(string access_token);\n    }\n     githubAuth = HttpApiClient.Create\u003cIGithubAuth\u003e();\n```\n\n### Websocket\n### Create wsclient\n```\nTextClient client = new TextClient(\"ws://echo.websocket.org\");\n```\n### send text\n```\n await client.Send(\"hello\");\n```\n### send and receive\n```\nvar resutl = await wss.ReceiveFrom(\"hello henry\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeetlex-io%2Fhttpclients","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeetlex-io%2Fhttpclients","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeetlex-io%2Fhttpclients/lists"}