{"id":21658527,"url":"https://github.com/twitchtv/twirp-example","last_synced_at":"2025-12-30T02:31:58.328Z","repository":{"id":53795885,"uuid":"123188675","full_name":"twitchtv/twirp-example","owner":"twitchtv","description":"Example Twirp service","archived":false,"fork":false,"pushed_at":"2021-04-16T22:00:48.000Z","size":625,"stargazers_count":20,"open_issues_count":1,"forks_count":11,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-10-15T09:15:53.084Z","etag":null,"topics":["go","protobuf","rpc","twirp"],"latest_commit_sha":null,"homepage":"https://twitchtv.github.io/twirp/docs/intro.html","language":"Go","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/twitchtv.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":"2018-02-27T21:07:27.000Z","updated_at":"2024-04-13T17:44:44.000Z","dependencies_parsed_at":"2022-09-07T20:22:50.222Z","dependency_job_id":null,"html_url":"https://github.com/twitchtv/twirp-example","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/twitchtv%2Ftwirp-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitchtv%2Ftwirp-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitchtv%2Ftwirp-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twitchtv%2Ftwirp-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twitchtv","download_url":"https://codeload.github.com/twitchtv/twirp-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226304767,"owners_count":17603672,"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":["go","protobuf","rpc","twirp"],"created_at":"2024-11-25T09:29:25.460Z","updated_at":"2025-12-30T02:31:58.300Z","avatar_url":"https://github.com/twitchtv.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# twirp-example\n\nThis is an exmaple Twirp service for educational purposes. Learn more about\nTwirp at its [website](https://twitchtv.github.io/twirp/docs/intro.html) or\n[repo](https://github.com/twitchtv/twirp).\n\n## Try it out\n\nFirst, download this repo with the Go tool:\n```\ngo get github.com/twitchtv/twirp-example/...\ncd $GOPATH/src/github.com/twitchtv/twirp-example\n```\n\nNext, try building the client and server binaries:\n```\ngo build ./cmd/client\ngo build ./cmd/server\n```\n\nAnd run them. In one terminal session:\n```\n./server\n```\n\nAnd in another:\n```\n./client\n```\n\nIn the client, you should see something like this:\n```\n-\u003e % ./client\nsize:12 color:\"red\" name:\"baseball cap\"\n```\n\nIn the server, something like this:\n```% ./server\nreceived req svc=\"Haberdasher\" method=\"MakeHat\"\nresponse sent svc=\"Haberdasher\" method=\"MakeHat\" time=\"109.01µs\"\n```\n\n## Code structure\n\nThe protobuf definition for the service lives in\n`rpc/haberdasher/haberdasher.proto`. The `rpc` directory name is a good way to\nsignal where your service definitions reside.\n\nThe generated Twirp and Go protobuf code is in the same directory. This makes it\neasy to import for both internal and external users - internally, we need to\nimport it to have the right types for our implmentation of the service\ninterface, and externally it needs to be available so clients can import it.\n\nThe implementation of the server is in `internal/haberdasherserver`. Putting it\nin `internal` means that it can't be imported from outside this repository,\nwhich is nice because we don't have to think about API stability nearly as much.\n\nIn addition, `internal/hooks/logging.go` has a file which provides\n[`ServerHooks`](https://twitchtv.github.io/twirp/docs/hooks.html) which can log\nrequests. This is a good demo of how you can use hooks to extend Twirp's basic\nfunctionality - you can use hooks to add instrumentation or even for\nauthentication.\n\nFinally, `cmd/server` and `cmd/client` wrap things together into executable main\npackages.\n\n## License\nThis library is licensed under the Apache 2.0 License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwitchtv%2Ftwirp-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwitchtv%2Ftwirp-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwitchtv%2Ftwirp-example/lists"}