{"id":22385236,"url":"https://github.com/acoshift/arpc","last_synced_at":"2025-07-31T04:32:59.599Z","repository":{"id":57498431,"uuid":"182207279","full_name":"acoshift/arpc","owner":"acoshift","description":"acoshift's opinionated HTTP-RPC styled api","archived":false,"fork":false,"pushed_at":"2023-03-22T00:38:24.000Z","size":58,"stargazers_count":15,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T17:13:52.335Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/acoshift.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":"2019-04-19T05:32:10.000Z","updated_at":"2023-12-27T06:53:25.000Z","dependencies_parsed_at":"2024-06-20T15:41:27.308Z","dependency_job_id":"bad4c66b-7da2-4b3b-bf1e-cba93bab6744","html_url":"https://github.com/acoshift/arpc","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Farpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Farpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Farpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acoshift%2Farpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acoshift","download_url":"https://codeload.github.com/acoshift/arpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228216487,"owners_count":17886565,"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-12-05T01:22:21.924Z","updated_at":"2024-12-05T01:22:22.380Z","avatar_url":"https://github.com/acoshift.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# arpc\n\n![Build Status](https://github.com/acoshift/arpc/actions/workflows/test.yaml/badge.svg?branch=master)\n[![codecov](https://codecov.io/gh/acoshift/arpc/branch/master/graph/badge.svg?token=3AMuow5vXh)](https://codecov.io/gh/acoshift/arpc)\n[![Go Report Card](https://goreportcard.com/badge/github.com/acoshift/arpc)](https://goreportcard.com/report/github.com/acoshift/arpc)\n[![GoDoc](https://pkg.go.dev/badge/github.com/acoshift/arpc)](https://pkg.go.dev/github.com/acoshift/arpc)\n\nARPC is the Acoshift's opinionated HTTP-RPC styled api\n\n## Installation\n\n```\ngo get -u github.com/acoshift/arpc/v2\n```\n\n## HTTP Status Code\n\nARPC will response http with only these 3 status codes\n\n- 200 OK - function works as expected\n- 400 Bad Request - developer (api caller) error, should never happened in production\n- 500 Internal Server Error - server error, should never happened (server broken)\n\n## Example Responses\n\n### Success Result\n\n```http\nHTTP/1.1 200 OK\nContent-Type: application/json; charset=utf-8\n\n{\n\t\"ok\": true,\n\t\"result\": {\n\t\t// result object\n\t}\n}\n```\n\n### Error Result\n\n- Validate error\n- Precondition failed\n- User error\n\n```http\nHTTP/1.1 200 OK\nContent-Type: application/json; charset=utf-8\n\n{\n\t\"ok\": false,\n\t\"error\": {\n\t\t\"message\": \"some error message\"\n\t}\n}\n```\n\n### Function not found\n\n- Developer (api caller) call not exists function\n\n```http\nHTTP/1.1 400 Bad Request\nContent-Type: application/json; charset=utf-8\n\n{\n\t\"ok\": false,\n\t\"error\": {\n\t\t\"message\": \"not found\"\n\t}\n}\n```\n\n### Unsupported Content-Type\n\n- Developer (api caller) send invalid content type\n\n```http\nHTTP/1.1 400 Bad Request\nContent-Type: application/json; charset=utf-8\n\n{\n\t\"ok\": false,\n\t\"error\": {\n\t\t\"message\": \"unsupported content type\"\n\t}\n}\n```\n\n### Internal Server Error\n\n- Server broken !!!\n\n```http\nHTTP/1.1 500 Internal Server Error\nContent-Type: application/json; charset=utf-8\n\n{\n\t\"ok\": false,\n\t\"error\": {} // internal error always return empty object\n}\n```\n\n## How to use\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"net/http\"\n\t\n\t\"github.com/acoshift/arpc/v2\"\n)\n\nfunc main() { \n\t// create new manager \n\tam := arpc.New()\n\n\tmux := http.NewServeMux()\n\tmux.Handle(\"/hello\", am.Handle(Hello))\n\t\n\t// start server \n\tlog.Fatal(http.ListenAndServe(\":8080\", mux))\n}\n\ntype HelloParams struct {\n\tName string `json:\"name\"`\n}\n\nfunc (r *HelloParams) Valid() error {\n\tif r.Name == \"\" {\n\t\treturn arpc.NewError(\"name required\")\n\t}\n\treturn nil\n}\n\ntype HelloResult struct {\n\tMessage string `json:\"message\"`\n}\n\nfunc Hello(ctx context.Context, req *HelloParams) (*HelloResult, error) {\n\treturn \u0026HelloResult{\n\t\tMessage: \"hello \" + req.Name,\n\t}, nil\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Farpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facoshift%2Farpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facoshift%2Farpc/lists"}