{"id":26590532,"url":"https://github.com/emcfarlane/larking","last_synced_at":"2026-03-04T12:31:53.060Z","repository":{"id":38380444,"uuid":"196878243","full_name":"emcfarlane/larking","owner":"emcfarlane","description":"Reflective protobuffer APIs","archived":false,"fork":false,"pushed_at":"2024-12-05T22:57:12.000Z","size":1320,"stargazers_count":65,"open_issues_count":21,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-14T17:39:18.087Z","etag":null,"topics":["go","golang","grpc","grpc-gateway","protobuf","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emcfarlane.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-07-14T20:03:09.000Z","updated_at":"2025-11-29T11:30:23.000Z","dependencies_parsed_at":"2024-06-21T14:27:33.287Z","dependency_job_id":"ed860f15-a948-45b1-a4bd-309c26bea5b4","html_url":"https://github.com/emcfarlane/larking","commit_stats":null,"previous_names":["afking/gateway","afking/graphpb","emcfarlane/graphpb","emcfarlane/larking","bufbuild/larking"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/emcfarlane/larking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcfarlane%2Flarking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcfarlane%2Flarking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcfarlane%2Flarking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcfarlane%2Flarking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emcfarlane","download_url":"https://codeload.github.com/emcfarlane/larking/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emcfarlane%2Flarking/sbom","scorecard":{"id":375028,"data":{"date":"2025-08-11","repo":{"name":"github.com/emcfarlane/larking","commit":"191f5a2ad1102341ec7a4c7849ac417589b864c9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/emcfarlane/larking/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/emcfarlane/larking/test.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":2,"reason":"8 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2024-2611 / GHSA-8r3f-844c-mc37"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 25 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T14:01:59.720Z","repository_id":38380444,"created_at":"2025-08-18T14:01:59.720Z","updated_at":"2025-08-18T14:01:59.720Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30079737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T12:28:08.313Z","status":"ssl_error","status_checked_at":"2026-03-04T12:27:28.210Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["go","golang","grpc","grpc-gateway","protobuf","rest-api"],"created_at":"2025-03-23T13:52:37.271Z","updated_at":"2026-03-04T12:31:53.027Z","avatar_url":"https://github.com/emcfarlane.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n   _,\n  ( '\u003e   Welcome to larking.io\n / ) )\n /|^^\n```\n[![Go Reference](https://pkg.go.dev/badge/larking.io.svg)](https://pkg.go.dev/larking.io/larking)\n\nLarking is a [protoreflect](https://pkg.go.dev/google.golang.org/protobuf/reflect/protoreflect) gRPC-transcoding implementation with support for gRPC, gRPC-web and twirp protocols.\nBind [`google.api.http`](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto) annotations to gRPC services without code generation.\nWorks with existing go-protobuf generators \n[`protoc-gen-go`](https://pkg.go.dev/google.golang.org/protobuf@v1.30.0/cmd/protoc-gen-go) and \n[`protoc-gen-go-grpc`](https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc)\nand Go's std library net/http stack.\nBind to local services or proxy to other gRPC servers using gRPC server reflection.\nUse Google's [API design guide](https://cloud.google.com/apis/design) to design beautiful RESTful APIs for your gRPC services.\n\n- Supports [gRPC](https://grpc.io) clients\n- Supports [gRPC-transcoding](https://cloud.google.com/endpoints/docs/grpc/transcoding) clients\n- Supports [gRPC-web](https://github.com/grpc/grpc-web) clients\n- Supports [twirp](https://github.com/twitchtv/twirp) clients\n- Proxy gRPC servers with gRPC [server reflection](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md)\n- Implicit `/GRPC_SERVICE_FULL_NAME/METHOD_NAME` for all methods\n- Google API service configuration [syntax](https://cloud.google.com/endpoints/docs/grpc-service-config/reference/rpc/google.api#using-grpc-api-service-configuration)\n- Websocket streaming with `websocket` kind annotations\n- Content streaming with `google.api.HttpBody`\n- Streaming support with [StreamCodec](https://github.com/emcfarlane/larking#streaming-codecs)\n- Fast with low allocations: see [benchmarks](https://github.com/emcfarlane/larking/tree/main/benchmarks)\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"docs/larking.svg\" /\u003e\n\u003c/div\u003e\n\n## Install\n\n```\ngo get larking.io@latest\n```\n\n## Quickstart\n\nCompile protobuffers with go and go-grpc libraries. Follow the guide [here](https://grpc.io/docs/languages/go/quickstart/#prerequisites). No other pre-compiled libraries are required. We need to create a `larking.Mux` and optionally `larking.Server` to serve both gRPC and REST. \n\nThis example builds a server with the health service:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net\"\n\n\t\"google.golang.org/genproto/googleapis/api/serviceconfig\"\n\thealthpb \"google.golang.org/grpc/health/grpc_health_v1\"\n\t\"larking.io/health\"\n\t\"larking.io/larking\"\n)\n\nfunc main() {\n\t// Create a health service. The health service is used to check the status\n\t// of services running within the server.\n\thealthSvc := health.NewServer()\n\thealthSvc.SetServingStatus(\"example.up.Service\", healthpb.HealthCheckResponse_SERVING)\n\thealthSvc.SetServingStatus(\"example.down.Service\", healthpb.HealthCheckResponse_NOT_SERVING)\n\n\tserviceConfig := \u0026serviceconfig.Service{}\n\t// AddHealthz adds a /v1/healthz endpoint to the service binding to the\n\t// grpc.health.v1.Health service:\n\t//   - get /v1/healthz -\u003e grpc.health.v1.Health.Check\n\t//   - websocket /v1/healthz -\u003e grpc.health.v1.Health.Watch\n\thealth.AddHealthz(serviceConfig)\n\n\t// Mux impements http.Handler and serves both gRPC and HTTP connections.\n\tmux, err := larking.NewMux(\n\t\tlarking.ServiceConfigOption(serviceConfig),\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t// RegisterHealthServer registers a HealthServer to the mux.\n\thealthpb.RegisterHealthServer(mux, healthSvc)\n\n\t// Server creates a *http.Server.\n\tsvr, err := larking.NewServer(mux)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Listen on TCP port 8080 on all interfaces.\n\tlis, err := net.Listen(\"tcp\", \"localhost:8080\")\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to listen: %v\", err)\n\t}\n\tdefer lis.Close()\n\n\t// Serve starts the server and blocks until the server stops.\n\t// http://localhost:8080/v1/healthz\n\tlog.Println(\"gRPC \u0026 HTTP server listening on\", lis.Addr())\n\tif err := svr.Serve(lis); err != nil {\n\t\tlog.Fatalf(\"failed to serve: %v\", err)\n\t}\n```\n\nRunning the service we can check the health endpoints with curl:\n```sh\n\u003e curl localhost:8080/grpc.health.v1.Health/Check\n{\"status\":\"SERVING\"}\n```\n\nTo filter by service you can post the body `{\"service\": \"example.down.Service\"}` or use query params:\n```sh\n\u003e curl 'localhost:8080/grpc.health.v1.Health/Check?service=example.down.Service'\n{\"status\":\"NOT_SERVING\"}\n```\n\nWe can also use the `/v1/healthz` endpoint added by `health.AddHealthz`:\n```sh\n\u003e curl 'localhost:8080/v1/healthz?service=example.up.Service'\n{\"status\":\"SERVING\"}\n```\n\n## Features\n\nTranscoding provides methods to bind gRPC endpoints to HTTP methods.\nAn example service `Library`:\n```protobuf\npackage larking.example\n\nservice Library {\n  // GetBook returns a book from a shelf.\n  rpc GetBook(GetBookRequest) returns (Book) {};\n}\n```\n\nImplicit bindings are provided on all methods bound to the URL\n`/GRPC_SERVICE_FULL_NAME/METHOD_NAME`.\n \nFor example to get the book with curl we can send a `POST` request:\n```\ncurl -XPOST http://domain/larking.example.Library/GetBook -d '{\"name\":\"shelves/1/books/2\"}\n```\n\nWe can also use any method with query parameters. The equivalent `GET` request:\n```\ncurl http://domain/larking.example.Library/GetBook?name=shelves/1/books/2\n```\n\nAs an annotation this syntax would be written as a custom http option:\n```protobuf\nrpc GetBook(GetBookRequest) returns (Book) {\n  option (google.api.http) = {\n    custom : {kind : \"*\" path : \"/larking.example.Library/GetBook\"}\n    body : \"*\"\n  };\n};\n```\n\nTo get better URL semantics lets define a custom annotation:\n```protobuf\nrpc GetBook(GetBookRequest) returns (Book) {\n  option (google.api.http) = {\n    get : \"/v1/{name=shelves/*/books/*}\"\n  };\n};\n```\n\nNow the equivalent `GET` request would be:\n```\ncurl http://domain/v1/shelves/1/books/2\n```\n\nSee the reference docs for [google.api.HttpRule](https://cloud.google.com/endpoints/docs/grpc-service-config/reference/rpc/google.api#google.api.HttpRule) type for all features.\n\n### Extensions\nIt aims to be a superset of the gRPC transcoding spec with better support for streaming. The implementation also aims to be simple and fast.\nAPI's should be easy to use and have low overhead.\nSee the `benchmarks/` for details and comparisons.\n\n#### Arbitrary Content\n\nSend any content type with the protobuf type `google.api.HttpBody`.\nRequest bodies are unmarshalled from the body with the `ContentType` header.\nResponse bodies marshal to the body and set the `ContentType` header.\nFor large requests streaming RPCs support chunking the file into multiple messages.\n\n```protobuf\nimport \"google/api/httpbody.proto\";\n\nservice Files {\n  // HTTP | gRPC\n  // -----|-----\n  // `POST /files/cat.jpg \u003cbody\u003e` | `UploadDownload(filename: \"cat.jpg\", file:\n  // { content_type: \"image/jpeg\", data: \u003cbody\u003e})\"`\n  rpc UploadDownload(UploadFileRequest) returns (google.api.HttpBody) {\n    option (google.api.http) = {\n      post : \"/files/{filename}\"\n      body : \"file\"\n    };\n  }\n  rpc LargeUploadDownload(stream UploadFileRequest)\n      returns (stream google.api.HttpBody) {\n    option (google.api.http) = {\n      post : \"/files/large/{filename}\"\n      body : \"file\"\n    };\n  }\n}\nmessage UploadFileRequest {\n  string filename = 1;\n  google.api.HttpBody file = 2;\n}\n```\n\nTo better support stream uploads use the `AsHTTPBodyReader` and `AsHTTPBodyWriter` methods.\nThe returned `io.Reader` and `io.Writer` efficiently stream bytes for large messages.\nThis methods only works on streaming requests or streaming responses for gRPC-transcoding streams.\n```go\n// LargeUploadDownload echoes the request body as the response body with contentType.\nfunc (s *asHTTPBodyServer) LargeUploadDownload(stream testpb.Files_LargeUploadDownloadServer) error {\n\tvar req testpb.UploadFileRequest\n\tr, _ := larking.AsHTTPBodyReader(stream, \u0026req)\n\tlog.Printf(\"got %s!\", req.Filename)\n\n\trsp := httpbody.HttpBody{\n\t\tContentType: req.File.GetContentType(),\n\t}\n\tw, _ := larking.AsHTTPBodyWriter(stream, \u0026rsp)\n\n\t_, err := io.Copy(w, r)\n\treturn err\n}\n```\n\n#### Websockets Annotations\nAnnotate a custom method kind `websocket` to enable clients to upgrade connections. This enables streams to be bidirectional over a websocket connection.\n```protobuf\n// Chatroom shows the websocket extension.\nservice ChatRoom {\n  rpc Chat(stream ChatMessage) returns (stream ChatMessage) {\n    option (google.api.http) = {\n      custom : {kind : \"websocket\" path : \"/v1/{name=rooms/*}\"}\n      body : \"*\"\n    };\n  }\n}\n```\n\n#### Streaming Codecs\nStreaming requests will upgrade the codec interface to read and write marshalled messages to the stream.\nControl of framing is given to the application on a per content type basis.\nIf the underlying protocol has it's own message framing, like 'websockets', streaming codecs won't be used.\nUnlike gRPC streams where compression is _per message_ here the compression is per _stream_ so only a message delimiter is needed.\nSee the [StreamCodec](https://pkg.go.dev/larking.io/larking#StreamCodec) docs for implementation details.\n- Protobuf messages use a varint delimiter encoding: `\u003cvarint\u003e\u003cbinary-message\u003e`.\n- JSON messages are delimited on the outer JSON braces `{\u003cfields\u003e}`.\n- Arbitrary content is delimited by the message size limit, chunking into bytes slices of length limit.\n\nTo stream json we can append payloads together as a single payload:\n```\ncurl -XPOST http://larking.io/v1/streaming -d '{\"message\":\"one\"}{\"message\":\"two\"}'\n```\nThe above creates an input stream of two messages.\n(N.B. when using HTTP/1 fully bidirectional streaming is not possible. All stream messages must be written before receiving a response)\n\nTo stream protobuf we can use [protodelim](https://pkg.go.dev/google.golang.org/protobuf@v1.30.0/encoding/protodelim) to read and write varint streams of messages. Similar libraries are found in other [languages](https://github.com/protocolbuffers/protobuf/issues/10229).\n\n#### Twirp\nTwirp is supported through gRPC-transcoding with the implicit methods.\nThe implicit methods cover `POST /package.Service/Method/` matching the content types for both `application/json` and `application/proto`.\nBefore the [v7 spec](https://twitchtv.github.io/twirp/docs/spec_v7.html) the URL required the `/twirp` prefix.\nWe can encode the server to use a ServerOption:\n```go\nsvr, _ := larking.NewServer(mux,\n  larking.MuxHandleOption(\"/\", \"/twirp\"), // Serve mux on '/' and '/twirp'\n)\n```\n\nTwirp [errors](https://twitchtv.github.io/twirp/docs/errors.html) are created from `*grpc.Status` errors.\nCode enums are mapped to twirp error strings and messages. Currently meta fields aren't supported.\nErrors will only be converted to twirp errors when the header `Twirp-Version` is set.\nThis is used to identify a twirp request.\n\n#### External Configuration\nMux can be configured with external rules using [`*serviceconfig.Service`](https://pkg.go.dev/google.golang.org/genproto/googleapis/api/serviceconfig). Load the file from yaml defintions or declare in Go.\n\n```go\nmux, _ := larking.NewMux(\n  larking.ServiceConfigOption(sc), // sc type of *serviceconfig.Service\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femcfarlane%2Flarking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femcfarlane%2Flarking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femcfarlane%2Flarking/lists"}