summaryrefslogtreecommitdiff
path: root/vendor/github.com
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-23 12:45:26 -0600
committermo khan <mo@mokhan.ca>2025-07-23 12:45:26 -0600
commit8ee0c453f6a6e719e69299f1949f48e289b33235 (patch)
tree46025e168b7f3928b3f1c51f706a862c08e32cf6 /vendor/github.com
parentd2ebd0a9afed57ba11f053266e6ae1edb84a0f36 (diff)
chore: update vendored modules
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/twitchtv/twirp/.gitignore6
-rw-r--r--vendor/github.com/twitchtv/twirp/.travis.yml10
-rw-r--r--vendor/github.com/twitchtv/twirp/CONTRIBUTING.md92
-rw-r--r--vendor/github.com/twitchtv/twirp/Gopkg.lock96
-rw-r--r--vendor/github.com/twitchtv/twirp/Gopkg.toml25
-rw-r--r--vendor/github.com/twitchtv/twirp/LICENSE202
-rw-r--r--vendor/github.com/twitchtv/twirp/Makefile28
-rw-r--r--vendor/github.com/twitchtv/twirp/NOTICE2
-rw-r--r--vendor/github.com/twitchtv/twirp/PROTOCOL.md215
-rw-r--r--vendor/github.com/twitchtv/twirp/README.md74
-rw-r--r--vendor/github.com/twitchtv/twirp/THIRD_PARTY29
-rw-r--r--vendor/github.com/twitchtv/twirp/check_protoc_version.sh28
-rw-r--r--vendor/github.com/twitchtv/twirp/client_options.go196
-rw-r--r--vendor/github.com/twitchtv/twirp/context.go142
-rw-r--r--vendor/github.com/twitchtv/twirp/ctxsetters/ctxsetters.go47
-rw-r--r--vendor/github.com/twitchtv/twirp/errors.go428
-rw-r--r--vendor/github.com/twitchtv/twirp/interceptors.go72
-rw-r--r--vendor/github.com/twitchtv/twirp/internal/contextkeys/keys.go28
-rw-r--r--vendor/github.com/twitchtv/twirp/logo.pngbin8279 -> 0 bytes
-rw-r--r--vendor/github.com/twitchtv/twirp/server_options.go242
-rw-r--r--vendor/github.com/twitchtv/twirp/tools.json17
-rw-r--r--vendor/github.com/twitchtv/twirp/version_constant.go22
-rw-r--r--vendor/github.com/xlgmokha/x/pkg/x/error.go4
23 files changed, 4 insertions, 2001 deletions
diff --git a/vendor/github.com/twitchtv/twirp/.gitignore b/vendor/github.com/twitchtv/twirp/.gitignore
deleted file mode 100644
index 6865b76..0000000
--- a/vendor/github.com/twitchtv/twirp/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-*.test
-npm-debug.log
-
-/bin
-/release
-/build
diff --git a/vendor/github.com/twitchtv/twirp/.travis.yml b/vendor/github.com/twitchtv/twirp/.travis.yml
deleted file mode 100644
index 718489e..0000000
--- a/vendor/github.com/twitchtv/twirp/.travis.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-sudo: false
-language: go
-go:
-- 1.13.x
-- 1.14.x
-- 1.15.x
-- tip
-script:
-- go install ./...
-- go test -race ./...
diff --git a/vendor/github.com/twitchtv/twirp/CONTRIBUTING.md b/vendor/github.com/twitchtv/twirp/CONTRIBUTING.md
deleted file mode 100644
index e80854b..0000000
--- a/vendor/github.com/twitchtv/twirp/CONTRIBUTING.md
+++ /dev/null
@@ -1,92 +0,0 @@
-# Contributing
-
-Thanks for helping make Twirp better! This is great!
-
-## Twirp Design Principles
-
-Contributions to Twirp should align with the project’s design principles:
-
-- Maintain backwards compatibility. Twirp has been in production at Twitch since 2016 and released to the public in January 2018. It is currently used by many companies and individuals with a variety of needs. There must be a compelling use-case and solid reasoning behind a major version upgrade.
-- Simple wire protocol and minimal public API. Fewer things in the core means fewer things to break. In addition, it ensures lower friction updates and easier to maintain implementations in other languages.
-- Avoid surprising behavior. For instance, mechanisms that can alter a program’s control flow in a surprising way (such as middleware or observability hooks) should be treated with caution.
-- Prefer pragmatism over bleeding-edge. Users should be able to deploy and accept updates to Twirp even if they are conservative on updating its dependencies. This includes Go, the protobuf compiler and runtime libraries, and the HTTP protocol.
-- Keep configuration to a minimum. For example: avoid adding flags to code generation commands, so that generated code is predictable across versions and platforms.
-- Limit dependencies where possible, so that they are easier to integrate and upgrade.
-- Prefer generated code over shared libraries between services and clients, so that it is easier to implement changes without forcing a lock-step upgrade across the ecosystem.
-
-Examples of contributions that should be addressed with high priority:
-
-- Security updates.
-- Performance improvements.
-- Supporting new versions of key dependencies such as Go and Protobuf.
-- Documentation.
-- Making Twirp easier to integrate with other tools.
-
-## Report an Issue
-
-If you have run into a bug or want to discuss a new feature, please [file an issue](https://github.com/twitchtv/twirp/issues). If you'd rather not publicly discuss the issue, please email security@twitch.tv.
-
-## Contributing Code with Pull Requests
-
-Twirp uses github pull requests. Fork, hack away at your changes and submit. Most pull requests will go through a few iterations before they get merged. Different contributors will sometimes have different opinions, and often patches will need to be revised before they can get merged.
-
-### Requirements
-
-- Add tests that cover your contribution. Overall code coverage should not decrease.
-- Twirp officially supports the last 3 releases of Go.
-- Protobuf version 3.x.x to generate code with the protoc command.
-- For linters and other tools, we use [retool](https://github.com/twitchtv/retool). If `make setup` is not able to install it, you can install it in your path with `go get github.com/twitchtv/retool` and then install tools with `retool build`.
-
-### Running tests
-
-Generally you want to make changes and run `make`, which will install all
-dependencies we know about, build the core, and run tests. A few notes:
-
-- Clone the repo on `$GOPATH/src/github.com/twitchtv/twirp` (go modules not supported yet).
-- Run Go unit tests with `make test`.
-- Most tests of the Go server are in `internal/twirptest/service_test.go`.
-- Integration tests running the full stack in Go are in the [clientcompat](./clientcompat) directory.
-
-## Contributing Documentation
-
-Twirp's docs are generated with [Docusaurus](https://docusaurus.io/). You can safely edit anything inside the [docs](./docs) directory, adding new pages or editing them. You can edit the sidebar by editing [website/sidebars.json](./website/sidebars.json).
-
-To render and review your changes, run docusaurus's local server. See [Install docusaurus on your machine](https://docusaurus.io/docs/en/installation.html).
-
-1. `cd website`
-2. `npm install`
-3. `npm start`
-4. Navigate to http://localhost:3000/twirp to see how it looks.
-
-Publish the new docs on the `gh-pages` branch. See [this guide](https://docusaurus.io/docs/en/tutorial-publish-site) for details.
-
-```
-GIT_USER=<your-github-username> CURRENT_BRANCH=gh-pages USE_SSH=true npm run publish-gh-pages
-```
-
-## Making a New Release
-
-Releasing versions is the responsibility of the core maintainers. Most people
-can skip this section.
-
-Twirp uses Github releases. To make a new release:
-
-1. Merge all changes that should be included in the release into the main branch.
-2. Update the version constant in `internal/gen/version.go`. Please respect [semantic versioning](http://semver.org/): `v<major>.<minor>.<patch>`.
-3. Run `make test_all` to re-generate code and run tests. Check that generated test files include the new version in the header comment.
-4. Add a new commit to main with a message like "Version vX.X.X release" and push.
-5. Tag the commit you just made: `git tag vX.X.X` and `git push origin --tags`.
-6. Go to Github https://github.com/twitchtv/twirp/releases and "Draft a new release".
-7. Make sure that all new functionality is properly documented, on code comments, PR description, and include links and/or upgrade instructions on the release. For example the [v7 release](https://github.com/twitchtv/twirp/releases/tag/v7.0.0). Minor releases can just include a link to the PR/PRs that were merged included into the release.
-
-## Code of Conduct
-
-This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
-For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
-opensource-codeofconduct@amazon.com with any additional questions or comments.
-
-## Licensing
-
-See the [LICENSE](https://github.com/twitchtv/twirp/blob/main/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
-
-We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
diff --git a/vendor/github.com/twitchtv/twirp/Gopkg.lock b/vendor/github.com/twitchtv/twirp/Gopkg.lock
deleted file mode 100644
index 90c1382..0000000
--- a/vendor/github.com/twitchtv/twirp/Gopkg.lock
+++ /dev/null
@@ -1,96 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
- digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39"
- name = "github.com/davecgh/go-spew"
- packages = ["spew"]
- pruneopts = "NUT"
- revision = "346938d642f2ec3594ed81d874461961cd0faa76"
- version = "v1.1.0"
-
-[[projects]]
- digest = "1:5cf3f025cbee5951a4ee961de067c8a89fc95a5adabead774f82822efabab121"
- name = "github.com/pkg/errors"
- packages = ["."]
- pruneopts = "NUT"
- revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
- version = "v0.8.0"
-
-[[projects]]
- digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe"
- name = "github.com/pmezard/go-difflib"
- packages = ["difflib"]
- pruneopts = "NUT"
- revision = "792786c7400a136282c1664665ae0a8db921c6c2"
- version = "v1.0.0"
-
-[[projects]]
- digest = "1:be7d615463b5c9c5fd732a3cc028038e8643543def6e55344b52a3a4dbb667a3"
- name = "github.com/stretchr/testify"
- packages = [
- "assert",
- "require",
- ]
- pruneopts = "NUT"
- revision = "b91bfb9ebec76498946beb6af7c0230c7cc7ba6c"
- version = "v1.2.0"
-
-[[projects]]
- digest = "1:acaa96db5d83347d36134c23782eda554b73fb1ac5915bbcb39c67d9a168db00"
- name = "google.golang.org/protobuf"
- packages = [
- "encoding/protojson",
- "encoding/prototext",
- "encoding/protowire",
- "internal/descfmt",
- "internal/descopts",
- "internal/detrand",
- "internal/encoding/defval",
- "internal/encoding/json",
- "internal/encoding/messageset",
- "internal/encoding/tag",
- "internal/encoding/text",
- "internal/errors",
- "internal/filedesc",
- "internal/filetype",
- "internal/flags",
- "internal/genid",
- "internal/impl",
- "internal/order",
- "internal/pragma",
- "internal/set",
- "internal/strs",
- "internal/version",
- "proto",
- "reflect/protoreflect",
- "reflect/protoregistry",
- "runtime/protoiface",
- "runtime/protoimpl",
- "types/descriptorpb",
- "types/known/emptypb",
- "types/known/wrapperspb",
- "types/pluginpb",
- ]
- pruneopts = "NUT"
- revision = "f2d1f6cbe10b90d22296ea09a7217081c2798009"
- version = "v1.26.0"
-
-[solve-meta]
- analyzer-name = "dep"
- analyzer-version = 1
- input-imports = [
- "github.com/pkg/errors",
- "github.com/stretchr/testify/assert",
- "github.com/stretchr/testify/require",
- "google.golang.org/protobuf/encoding/protojson",
- "google.golang.org/protobuf/proto",
- "google.golang.org/protobuf/reflect/protoreflect",
- "google.golang.org/protobuf/runtime/protoimpl",
- "google.golang.org/protobuf/types/descriptorpb",
- "google.golang.org/protobuf/types/known/emptypb",
- "google.golang.org/protobuf/types/known/wrapperspb",
- "google.golang.org/protobuf/types/pluginpb",
- ]
- solver-name = "gps-cdcl"
- solver-version = 1
diff --git a/vendor/github.com/twitchtv/twirp/Gopkg.toml b/vendor/github.com/twitchtv/twirp/Gopkg.toml
deleted file mode 100644
index 0e6be4a..0000000
--- a/vendor/github.com/twitchtv/twirp/Gopkg.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-# The importable parts of Twirp have no external dependencies. They just use the
-# standard library. But both protoc-gen-twirp and Twirp's tests *do* have some
-# dependencies, and this manifest lists them.
-#
-# All dependencies are specified as overrides, not constraints, so that dep
-# doesn't get confused if someone imports Twirp. We don't want to falsely
-# require any particular versions of these libraries - they are *only* for
-# tests and building main packages.
-
-[[override]]
- name = "google.golang.org/protobuf"
- version = "1.26.0"
-
-[[override]]
- name = "github.com/pkg/errors"
- version = "0.8.0"
-
-[[override]]
- name = "github.com/stretchr/testify"
- version = "1.2.0"
-
-[prune]
- unused-packages = true
- go-tests = true
- non-go = true
diff --git a/vendor/github.com/twitchtv/twirp/LICENSE b/vendor/github.com/twitchtv/twirp/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/vendor/github.com/twitchtv/twirp/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/twitchtv/twirp/Makefile b/vendor/github.com/twitchtv/twirp/Makefile
deleted file mode 100644
index e3e6b4b..0000000
--- a/vendor/github.com/twitchtv/twirp/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-PATH := ${PWD}/_tools/bin:${PWD}/bin:${PATH}
-export GO111MODULE=off
-
-all: setup test_all
-
-.PHONY: setup generate test_all test test_clientcompat
-
-setup:
- ./check_protoc_version.sh
- GOPATH="$$PWD/_tools" GOBIN="$$PWD/_tools/bin" go get github.com/twitchtv/retool
- ./_tools/bin/retool build
-
-generate:
- # Recompile and install generator
- GOBIN="$$PWD/bin" go install -v ./protoc-gen-twirp
- # Generate code from go:generate comments
- go generate ./...
-
-test_all: setup test test_clientcompat
-
-test: generate
- ./_tools/bin/errcheck ./internal/twirptest
- go test -race ./...
-
-test_clientcompat: generate
- GOBIN="$$PWD/bin" go install ./clientcompat
- GOBIN="$$PWD/bin" go install ./clientcompat/gocompat
- ./bin/clientcompat -client ./bin/gocompat
diff --git a/vendor/github.com/twitchtv/twirp/NOTICE b/vendor/github.com/twitchtv/twirp/NOTICE
deleted file mode 100644
index de04251..0000000
--- a/vendor/github.com/twitchtv/twirp/NOTICE
+++ /dev/null
@@ -1,2 +0,0 @@
-Twirp
-Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
diff --git a/vendor/github.com/twitchtv/twirp/PROTOCOL.md b/vendor/github.com/twitchtv/twirp/PROTOCOL.md
deleted file mode 100644
index 8398c96..0000000
--- a/vendor/github.com/twitchtv/twirp/PROTOCOL.md
+++ /dev/null
@@ -1,215 +0,0 @@
-# Twirp Wire Protocol
-
-This document defines the Twirp wire protocol over HTTP. The
-current protocol version is v7.
-
-## Overview
-
-The Twirp wire protocol is a simple RPC protocol based on HTTP and
-Protocol Buffers (proto). The protocol uses HTTP URLs to specify the
-RPC endpoints, and sends/receives proto messages as HTTP
-request/response bodies.
-
-To use Twirp, developers first define their APIs using proto files,
-then use Twirp tools to generate the client and the server libraries.
-The generated libraries implement the Twirp wire protocol, using the
-standard HTTP library provided by the programming language runtime or
-the operating system. Once the client and the server are implemented,
-the client can communicate with the server by making RPC calls.
-
-The Twirp wire protocol supports both binary and JSON encodings of
-proto messages, and works with any HTTP client and any HTTP version.
-
-### URLs
-
-In [ABNF syntax](https://tools.ietf.org/html/rfc5234), Twirp's URLs
-have the following format:
-
-```abnf
-URL ::= Base-URL [ Prefix ] "/" [ Package "." ] Service "/" Method
-```
-
-The Twirp wire protocol uses HTTP URLs to specify the RPC
-endpoints on the server for sending the requests. Such direct mapping
-makes the request routing simple and efficient. The Twirp URLs have
-the following components.
-
-* **Base-URL** is the virtual location of a Twirp API server, which is
- typically published via API documentation or service discovery.
- Currently, it should only contain URL `scheme` and `authority`. For
- example, "https://example.com".
-* **Prefix** is usually "/twirp", but it could be empty "", or an
- arbitrary path like "/my/custom/prefix".
-* **Package** is the proto `package` name for an API, which is often
- considered as an API version. For example,
- `example.calendar.v1`. This component is omitted if the API
- definition doesn't have a package name.
-* **Service** is the proto `service` name for an API. For example,
- `CalendarService`.
-* **Method** is the proto `rpc` name for an API method. For example,
- `CreateEvent`.
-
-### Requests
-
-Twirp always uses HTTP POST method to send requests, because it
-closely matches the semantics of RPC methods.
-
-The **Request-Headers** are normal HTTP headers. The Twirp wire
-protocol uses the following headers.
-
-* **Content-Type** header indicates the proto message encoding, which
- should be one of "application/protobuf", "application/json". The
- server uses this value to decide how to parse the request body,
- and encode the response body.
-
-The **Request-Body** is the encoded request message, contained in the
-HTTP request body. The encoding is specified by the `Content-Type`
-header.
-
-### Responses
-
-The **Response-Headers** are just normal HTTP response headers. The
-Twirp wire protocol uses the following headers.
-
-* **Content-Type** The value should be either "application/protobuf"
- or "application/json" to indicate the encoding of the response
- message. It must match the "Content-Type" header in the request.
-
-The **Request-Body** is the encoded response message contained in the
-HTTP response body. The encoding is specified by the `Content-Type`
-header.
-
-### Example
-
-The following example shows a simple Echo API definition and its
-corresponding wire payloads.
-
-The example assumes the server base URL is "https://example.com".
-
-```proto
-syntax = "proto3";
-
-package example.echoer;
-
-service Echo {
- rpc Hello(HelloRequest) returns (HelloResponse);
-}
-
-message HelloRequest {
- string message;
-}
-
-message HelloResponse {
- string message;
-}
-```
-
-**Proto Request**
-
-```
-POST /twirp/example.echoer.Echo/Hello HTTP/1.1
-Host: example.com
-Content-Type: application/protobuf
-Content-Length: 15
-
-<encoded HelloRequest>
-```
-
-**JSON Request**
-
-```
-POST /twirp/example.echoer.Echo/Hello HTTP/1.1
-Host: example.com
-Content-Type: application/json
-Content-Length: 27
-
-{"message":"Hello, World!"}
-```
-
-**Proto Response**
-
-```
-HTTP/1.1 200 OK
-Content-Type: application/protobuf
-Content-Length: 15
-
-<encoded HelloResponse>
-```
-
-**JSON Response**
-
-```
-HTTP/1.1 200 OK
-Content-Type: application/json
-Content-Length: 27
-
-{"message":"Hello, World!"}
-```
-
-
-## Errors
-
-Twirp error responses are always JSON-encoded, regardless of
-the request's Content-Type, with a corresponding
-`Content-Type: application/json` header. This ensures that
-the errors are human-readable in any setting.
-
-Twirp errors are a JSON object with the keys:
-
-* **code**: One of the Twirp error codes as a string.
-* **msg**: A human-readable message describing the error
- as a string.
-* **meta**: (optional) An object with string values holding
- arbitrary additional metadata describing the error.
-
-Example:
-
-```json
-{
- "code": "internal",
- "msg": "Something went wrong"
-}
-```
-
-Example with metadata:
-
-```json
-{
- "code": "permission_denied",
- "msg": "Thou shall not pass",
- "meta": {
- "target": "Balrog",
- "power": "999"
- }
-}
-```
-
-### Error Codes
-
-Twirp errors always include an error code. This code is represented
-as a string and must be one of a fixed set of codes, listed in the
-table below. Each code has an associated HTTP Status Code. When a
-server responds with the given error code, it must set the
-corresponding HTTP Status Code for the response.
-
-| Twirp Error Code | HTTP Status | Description
-| ------------------- | ----------- | -----------
-| canceled | 408 | The operation was cancelled.
-| unknown | 500 | An unknown error occurred. For example, this can be used when handling errors raised by APIs that do not return any error information.
-| invalid_argument | 400 | The client specified an invalid argument. This indicates arguments that are invalid regardless of the state of the system (i.e. a malformed file name, required argument, number out of range, etc.).
-| malformed | 400 | The client sent a message which could not be decoded. This may mean that the message was encoded improperly or that the client and server have incompatible message definitions.
-| deadline_exceeded | 408 | Operation expired before completion. For operations that change the state of the system, this error may be returned even if the operation has completed successfully (timeout).
-| not_found | 404 | Some requested entity was not found.
-| bad_route | 404 | The requested URL path wasn't routable to a Twirp service and method. This is returned by generated server code and should not be returned by application code (use "not_found" or "unimplemented" instead).
-| already_exists | 409 | An attempt to create an entity failed because one already exists.
-| permission_denied | 403 | The caller does not have permission to execute the specified operation. It must not be used if the caller cannot be identified (use "unauthenticated" instead).
-| unauthenticated | 401 | The request does not have valid authentication credentials for the operation.
-| resource_exhausted | 429 | Some resource has been exhausted or rate-limited, perhaps a per-user quota, or perhaps the entire file system is out of space.
-| failed_precondition | 412 | The operation was rejected because the system is not in a state required for the operation's execution. For example, doing an rmdir operation on a directory that is non-empty, or on a non-directory object, or when having conflicting read-modify-write on the same resource.
-| aborted | 409 | The operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.
-| out_of_range | 400 | The operation was attempted past the valid range. For example, seeking or reading past end of a paginated collection. Unlike "invalid_argument", this error indicates a problem that may be fixed if the system state changes (i.e. adding more items to the collection). There is a fair bit of overlap between "failed_precondition" and "out_of_range". We recommend using "out_of_range" (the more specific error) when it applies so that callers who are iterating through a space can easily look for an "out_of_range" error to detect when they are done.
-| unimplemented | 501 | The operation is not implemented or not supported/enabled in this service.
-| internal | 500 | When some invariants expected by the underlying system have been broken. In other words, something bad happened in the library or backend service. Twirp specific issues like wire and serialization problems are also reported as "internal" errors.
-| unavailable | 503 | The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff.
-| data_loss | 500 | The operation resulted in unrecoverable data loss or corruption.
-
diff --git a/vendor/github.com/twitchtv/twirp/README.md b/vendor/github.com/twitchtv/twirp/README.md
deleted file mode 100644
index 9400995..0000000
--- a/vendor/github.com/twitchtv/twirp/README.md
+++ /dev/null
@@ -1,74 +0,0 @@
-![Twirp Logo](./logo.png) [![Build Status](https://travis-ci.org/twitchtv/twirp.svg?branch=main)](https://travis-ci.org/twitchtv/twirp) [![Go Report Card](https://goreportcard.com/badge/github.com/twitchtv/twirp)](https://goreportcard.com/report/github.com/twitchtv/twirp) [![GoDoc](https://godoc.org/github.com/twitchtv/twirp?status.svg)](https://godoc.org/github.com/twitchtv/twirp)
-
----
-
-Twirp is a framework for service-to-service communication emphasizing simplicity
-and minimalism. It generates routing and serialization from API definition files
-and lets you focus on your application's logic instead of thinking about
-folderol like HTTP methods and paths and JSON.
-
-Twirp is similar to [gRPC](http://www.grpc.io/), but without the custom
-HTTP server and transport implementations: it runs on the standard library's
-extremely-well-tested-and-high-performance `net/http` Server. It can run on HTTP
-1.1, not just http/2, and supports JSON serialization for easy debugging.
-
-Along the way, you get autogenerated clients and a simple, smart framework for
-passing error messages. Nice!
-
-Read more about the motivation behind on the [announcement blog post](https://blog.twitch.tv/en/2018/01/16/twirp-a-sweet-new-rpc-framework-for-go-5f2febbf35f/).
-
-### Documentation
-
- * [Getting Started](https://twitchtv.github.io/twirp/docs/intro.html)
- * [Usage Example](https://twitchtv.github.io/twirp/docs/example.html)
- * [Errors](https://twitchtv.github.io/twirp/docs/errors.html)
- * More: https://twitchtv.github.io/twirp/
-
-### Implementations in other languages
-
-This repo contains the generator and runtime library for the Go implementation.
-
-Here is a list of some third-party implementations in other languages.
-
-| Language | Clients | Servers | Repository |
-|----------------|---------|---------|------------|
-| **Python3** | ✓ | ✓ | [github.com/verloop/twirpy](https://github.com/verloop/twirpy)
-| **Java** | ✓ | ✓ | [github.com/fajran/protoc-gen-twirp_java_jaxrs](https://github.com/fajran/protoc-gen-twirp_java_jaxrs)
-| **Java** | | ✓ | [github.com/devork/flit](https://github.com/devork/flit)
-| **JavaScript** | ✓ | | [github.com/thechriswalker/protoc-gen-twirp_js](https://github.com/thechriswalker/protoc-gen-twirp_js)
-| **JavaScript** | ✓ | | [github.com/Xe/twirp-codegens/cmd/protoc-gen-twirp_jsbrowser](https://github.com/Xe/twirp-codegens)
-| **JavaScript** | ✓ | ✓ | [github.com/tatethurston/TwirpScript](https://github.com/tatethurston/TwirpScript)
-| **Typescript** | ✓ | ✓ | [github.com/hopin-team/twirp-ts](https://github.com/hopin-team/twirp-ts)
-| **Typescript** | ✓ | | [github.com/larrymyers/protoc-gen-twirp_typescript](https://github.com/larrymyers/protoc-gen-twirp_typescript)
-| **Typescript** | ✓ | ✓ | [github.com/tatethurston/TwirpScript](https://github.com/tatethurston/TwirpScript)
-| **Typescript** | ✓ | ✓ | [github.com/timostamm/protobuf-ts](https://github.com/timostamm/protobuf-ts)
-| **Ruby** | ✓ | ✓ | [github.com/twitchtv/twirp-ruby](https://github.com/twitchtv/twirp-ruby)
-| **Rust** | ✓ | ✓ | [github.com/cretz/prost-twirp](https://github.com/cretz/prost-twirp)
-| **Scala** | ✓ | ✓ | [github.com/soundcloud/twinagle](https://github.com/soundcloud/twinagle)
-| **Swagger** | ✓ | ✓ | [github.com/go-bridget/twirp-swagger-gen](https://github.com/go-bridget/twirp-swagger-gen)
-| **PHP** | ✓ | ✓ | [github.com/twirphp/twirp](https://github.com/twirphp/twirp)
-| **Dart** | ✓ | | [github.com/apptreesoftware/protoc-gen-twirp_dart](https://github.com/apptreesoftware/protoc-gen-twirp_dart)
-| **Elixir** | ✓ | ✓ | [github.com/keathley/twirp-elixir](https://github.com/keathley/twirp-elixir)
-| **Swift** | ✓ | | [github.com/CrazyHulk/protoc-gen-swiftwirp](https://github.com/CrazyHulk/protoc-gen-swiftwirp)
-| **Crystal** | ✓ | ✓ | [github.com/mloughran/twirp.cr](https://github.com/mloughran/twirp.cr)
-
-
-### Support and Community
-
-We have a channel on the Gophers slack, [#twirp](https://gophers.slack.com/messages/twirp),
-which is the best place to get quick answers to your questions. You can join the
-Gopher slack [here](https://invite.slack.golangbridge.org/).
-
-### Releases
-
-Twirp follows semantic versioning through git tags, and uses Github Releases for
-release notes and upgrade guides:
-[Twirp Releases](https://github.com/twitchtv/twirp/releases)
-
-### Contributing
-
-Check out [CONTRIBUTING.md](./CONTRIBUTING.md) for notes on making contributions.
-
-### License
-
-This library is licensed under the Apache 2.0 License.
diff --git a/vendor/github.com/twitchtv/twirp/THIRD_PARTY b/vendor/github.com/twitchtv/twirp/THIRD_PARTY
deleted file mode 100644
index 1c4588d..0000000
--- a/vendor/github.com/twitchtv/twirp/THIRD_PARTY
+++ /dev/null
@@ -1,29 +0,0 @@
-** Protobuf -- https://github.com/protocolbuffers/protobuf-go
-Copyright 2010 The Go Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
diff --git a/vendor/github.com/twitchtv/twirp/check_protoc_version.sh b/vendor/github.com/twitchtv/twirp/check_protoc_version.sh
deleted file mode 100644
index a6df258..0000000
--- a/vendor/github.com/twitchtv/twirp/check_protoc_version.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"). You may not
-# use this file except in compliance with the License. A copy of the License is
-# located at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# or in the "license" file accompanying this file. This file is distributed on
-# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-# express or implied. See the License for the specific language governing
-# permissions and limitations under the License.
-
-which protoc
-PROTOC_EXISTS=$?
-if [ $PROTOC_EXISTS -eq 0 ]; then
- PROTOC_VERSION=`protoc --version`
- if [[ $PROTOC_VERSION == "libprotoc 3."* ]]; then
- echo "protoc version: $PROTOC_VERSION"
- exit 0
- fi
- echo "required protoc v3, but found: $PROTOC_VERSION"
- exit 1
-fi
-echo "Please install protoc v3. See https://grpc.io/docs/protoc-installation/, for example in MacOS: brew install protobuf"
-exit 1
diff --git a/vendor/github.com/twitchtv/twirp/client_options.go b/vendor/github.com/twitchtv/twirp/client_options.go
deleted file mode 100644
index 36d57ac..0000000
--- a/vendor/github.com/twitchtv/twirp/client_options.go
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may not
-// use this file except in compliance with the License. A copy of the License is
-// located at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// or in the "license" file accompanying this file. This file is distributed on
-// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-package twirp
-
-import (
- "context"
- "net/http"
- "reflect"
-)
-
-// ClientOption is a functional option for extending a Twirp client.
-type ClientOption func(*ClientOptions)
-
-// WithClientHooks defines the hooks for a Twirp client.
-func WithClientHooks(hooks *ClientHooks) ClientOption {
- return func(opts *ClientOptions) {
- opts.Hooks = hooks
- }
-}
-
-// WithClientInterceptors defines the interceptors for a Twirp client.
-func WithClientInterceptors(interceptors ...Interceptor) ClientOption {
- return func(opts *ClientOptions) {
- opts.Interceptors = append(opts.Interceptors, interceptors...)
- }
-}
-
-// WithClientPathPrefix specifies a different prefix to use for routing.
-// If not specified, the "/twirp" prefix is used by default.
-// The service must be configured to serve on the same prefix.
-// An empty value "" can be speficied to use no prefix.
-// URL format: "<baseURL>[<prefix>]/<package>.<Service>/<Method>"
-// More info on Twirp docs: https://twitchtv.github.io/twirp/docs/routing.html
-func WithClientPathPrefix(prefix string) ClientOption {
- return func(opts *ClientOptions) {
- opts.setOpt("pathPrefix", prefix)
- opts.pathPrefix = &prefix // for code generated before v8.1.0
- }
-}
-
-// WithClientLiteralURLs configures the Twirp client to use the exact values
-// as defined in the proto file for Service and Method names,
-// fixing the issue https://github.com/twitchtv/twirp/issues/244, which is manifested
-// when working with Twirp services implemented other languages (e.g. Python) and the proto file definitions
-// are not properly following the [Protobuf Style Guide](https://developers.google.com/protocol-buffers/docs/style#services).
-// By default (false), Go clients modify the routes by CamelCasing the values. For example,
-// with Service: `haberdasher`, Method: `make_hat`, the URLs generated by Go clients are `Haberdasher/MakeHat`,
-// but with this option enabled (true) the client will properly use `haberdasher/make_hat` instead.
-func WithClientLiteralURLs(b bool) ClientOption {
- return func(opts *ClientOptions) {
- opts.setOpt("literalURLs", b)
- opts.LiteralURLs = b // for code generated before v8.1.0
- }
-}
-
-// ClientHooks is a container for callbacks that can instrument a
-// Twirp-generated client. These callbacks all accept a context and some return
-// a context. They can use this to add to the context, appending values or
-// deadlines to it.
-//
-// The RequestPrepared hook is special because it can return errors. If it
-// returns non-nil error, handling for that request will be stopped at that
-// point. The Error hook will then be triggered.
-//
-// The RequestPrepared hook will always be called first and will be called for
-// each outgoing request from the Twirp client. The last hook to be called
-// will either be Error or ResponseReceived, so be sure to handle both cases in
-// your hooks.
-type ClientHooks struct {
- // RequestPrepared is called as soon as a request has been created and before
- // it has been sent to the Twirp server.
- RequestPrepared func(context.Context, *http.Request) (context.Context, error)
-
- // ResponseReceived is called after a request has finished sending. Since this
- // is terminal, the context is not returned. ResponseReceived will not be
- // called in the case of an error being returned from the request.
- ResponseReceived func(context.Context)
-
- // Error hook is called whenever an error occurs during the sending of a
- // request. The Error is passed as an argument to the hook.
- Error func(context.Context, Error)
-}
-
-// ChainClientHooks creates a new *ClientHooks which chains the callbacks in
-// each of the constituent hooks passed in. Each hook function will be
-// called in the order of the ClientHooks values passed in.
-//
-// For the erroring hook, RequestPrepared, any returned
-// errors prevent processing by later hooks.
-func ChainClientHooks(hooks ...*ClientHooks) *ClientHooks {
- if len(hooks) == 0 {
- return nil
- }
- if len(hooks) == 1 {
- return hooks[0]
- }
- return &ClientHooks{
- RequestPrepared: func(ctx context.Context, req *http.Request) (context.Context, error) {
- for _, h := range hooks {
- if h != nil && h.RequestPrepared != nil {
- var err error
- ctx, err = h.RequestPrepared(ctx, req)
- if err != nil {
- return ctx, err
- }
- }
- }
- return ctx, nil
- },
- ResponseReceived: func(ctx context.Context) {
- for _, h := range hooks {
- if h != nil && h.ResponseReceived != nil {
- h.ResponseReceived(ctx)
- }
- }
- },
- Error: func(ctx context.Context, twerr Error) {
- for _, h := range hooks {
- if h != nil && h.Error != nil {
- h.Error(ctx, twerr)
- }
- }
- },
- }
-}
-
-// ClientOptions encapsulate the configurable parameters on a Twirp client.
-// This type is meant to be used only by generated code.
-type ClientOptions struct {
- // Untyped options map. The methods setOpt and ReadOpt are used to set
- // and read options. The options are untyped so when a new option is added,
- // newly generated code can still work with older versions of the runtime.
- m map[string]interface{}
-
- Hooks *ClientHooks
- Interceptors []Interceptor
-
- // Properties below are only used by code that was
- // generated by older versions of Twirp (before v8.1.0).
- // New options with standard types added in the future
- // don't need new properties, they should use ReadOpt.
- LiteralURLs bool
- pathPrefix *string
-}
-
-// ReadOpt extracts an option to a pointer value,
-// returns true if the option exists and was extracted.
-// This method is meant to be used by generated code,
-// keeping the type dependency outside of the runtime.
-//
-// Usage example:
-//
-// opts.setOpt("fooOpt", 123)
-// var foo int
-// ok := opts.ReadOpt("fooOpt", &int)
-//
-func (opts *ClientOptions) ReadOpt(key string, out interface{}) bool {
- val, ok := opts.m[key]
- if !ok {
- return false
- }
-
- rout := reflect.ValueOf(out)
- if rout.Kind() != reflect.Ptr {
- panic("ReadOpt(key, out); out must be a pointer but it was not")
- }
- rout.Elem().Set(reflect.ValueOf(val))
- return true
-}
-
-// setOpt adds an option key/value. It is used by ServerOption helpers.
-// The value can be extracted with ReadOpt by passing a pointer to the same type.
-func (opts *ClientOptions) setOpt(key string, val interface{}) {
- if opts.m == nil {
- opts.m = make(map[string]interface{})
- }
- opts.m[key] = val
-}
-
-// PathPrefix() is used only by clients generated before v8.1.0
-func (opts *ClientOptions) PathPrefix() string {
- if opts.pathPrefix == nil {
- return "/twirp" // default prefix
- }
- return *opts.pathPrefix
-}
diff --git a/vendor/github.com/twitchtv/twirp/context.go b/vendor/github.com/twitchtv/twirp/context.go
deleted file mode 100644
index eb8ff94..0000000
--- a/vendor/github.com/twitchtv/twirp/context.go
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may not
-// use this file except in compliance with the License. A copy of the License is
-// located at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// or in the "license" file accompanying this file. This file is distributed on
-// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-
-package twirp
-
-import (
- "context"
- "errors"
- "net/http"
-
- "github.com/twitchtv/twirp/internal/contextkeys"
-)
-
-// MethodName extracts the name of the method being handled in the given
-// context. If it is not known, it returns ("", false).
-func MethodName(ctx context.Context) (string, bool) {
- name, ok := ctx.Value(contextkeys.MethodNameKey).(string)
- return name, ok
-}
-
-// ServiceName extracts the name of the service handling the given context. If
-// it is not known, it returns ("", false).
-func ServiceName(ctx context.Context) (string, bool) {
- name, ok := ctx.Value(contextkeys.ServiceNameKey).(string)
- return name, ok
-}
-
-// PackageName extracts the fully-qualified protobuf package name of the service
-// handling the given context. If it is not known, it returns ("", false). If
-// the service comes from a proto file that does not declare a package name, it
-// returns ("", true).
-//
-// Note that the protobuf package name can be very different than the go package
-// name; the two are unrelated.
-func PackageName(ctx context.Context) (string, bool) {
- name, ok := ctx.Value(contextkeys.PackageNameKey).(string)
- return name, ok
-}
-
-// StatusCode retrieves the status code of the response (as string like "200").
-// If it is known returns (status, true).
-// If it is not known, it returns ("", false).
-func StatusCode(ctx context.Context) (string, bool) {
- code, ok := ctx.Value(contextkeys.StatusCodeKey).(string)
- return code, ok
-}
-
-// WithHTTPRequestHeaders stores an http.Header in a context.Context. When
-// using a Twirp-generated client, you can pass the returned context
-// into any of the request methods, and the stored header will be
-// included in outbound HTTP requests.
-//
-// This can be used to set custom HTTP headers like authorization tokens or
-// client IDs. But note that HTTP headers are a Twirp implementation detail,
-// only visible by middleware, not by the server implementation.
-//
-// WithHTTPRequestHeaders returns an error if the provided http.Header
-// would overwrite a header that is needed by Twirp, like "Content-Type".
-func WithHTTPRequestHeaders(ctx context.Context, h http.Header) (context.Context, error) {
- if _, ok := h["Accept"]; ok {
- return nil, errors.New("provided header cannot set Accept")
- }
- if _, ok := h["Content-Type"]; ok {
- return nil, errors.New("provided header cannot set Content-Type")
- }
- if _, ok := h["Twirp-Version"]; ok {
- return nil, errors.New("provided header cannot set Twirp-Version")
- }
-
- copied := make(http.Header, len(h))
- for k, vv := range h {
- if vv == nil {
- copied[k] = nil
- continue
- }
- copied[k] = make([]string, len(vv))
- copy(copied[k], vv)
- }
-
- return context.WithValue(ctx, contextkeys.RequestHeaderKey, copied), nil
-}
-
-func HTTPRequestHeaders(ctx context.Context) (http.Header, bool) {
- h, ok := ctx.Value(contextkeys.RequestHeaderKey).(http.Header)
- return h, ok
-}
-
-// SetHTTPResponseHeader sets an HTTP header key-value pair using a context
-// provided by a twirp-generated server, or a child of that context.
-// The server will include the header in its response for that request context.
-//
-// This can be used to respond with custom HTTP headers like "Cache-Control".
-// But note that HTTP headers are a Twirp implementation detail,
-// only visible by middleware, not by the clients or their responses.
-//
-// The header will be ignored (noop) if the context is invalid (i.e. using a new
-// context.Background() instead of passing the context from the handler).
-//
-// If called multiple times with the same key, it replaces any existing values
-// associated with that key.
-//
-// SetHTTPResponseHeader returns an error if the provided header key
-// would overwrite a header that is needed by Twirp, like "Content-Type".
-func SetHTTPResponseHeader(ctx context.Context, key, value string) error {
- if key == "Content-Type" {
- return errors.New("header key can not be Content-Type")
- }
-
- responseWriter, ok := ctx.Value(contextkeys.ResponseWriterKey).(http.ResponseWriter)
- if ok {
- responseWriter.Header().Set(key, value)
- } // invalid context is ignored, not an error, this is to allow easy unit testing with mock servers
-
- return nil
-}
-
-// AddHTTPResponseHeader behaves like SetHTTPResponseHeader,
-// but it appends the key-value pair to the header (instead of replacing it).
-//
-// AddHTTPResponseHeader returns an error if the key is "Content-Type".
-func AddHTTPResponseHeader(ctx context.Context, key, value string) error {
- if key == "Content-Type" {
- return errors.New("header key can not be Content-Type")
- }
-
- responseWriter, ok := ctx.Value(contextkeys.ResponseWriterKey).(http.ResponseWriter)
- if ok {
- responseWriter.Header().Add(key, value)
- } // invalid context is ignored, not an error, this is to allow easy unit testing with mock servers
-
- return nil
-}
diff --git a/vendor/github.com/twitchtv/twirp/ctxsetters/ctxsetters.go b/vendor/github.com/twitchtv/twirp/ctxsetters/ctxsetters.go
deleted file mode 100644
index 3294da7..0000000
--- a/vendor/github.com/twitchtv/twirp/ctxsetters/ctxsetters.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may not
-// use this file except in compliance with the License. A copy of the License is
-// located at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// or in the "license" file accompanying this file. This file is distributed on
-// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-
-// Package ctxsetters is an implementation detail for twirp generated code, used
-// by the generated servers to set values in contexts for later access with the
-// twirp package's accessors.
-//
-// Do not use ctxsetters outside of twirp's generated code.
-package ctxsetters
-
-import (
- "context"
- "net/http"
- "strconv"
-
- "github.com/twitchtv/twirp/internal/contextkeys"
-)
-
-func WithMethodName(ctx context.Context, name string) context.Context {
- return context.WithValue(ctx, contextkeys.MethodNameKey, name)
-}
-
-func WithServiceName(ctx context.Context, name string) context.Context {
- return context.WithValue(ctx, contextkeys.ServiceNameKey, name)
-}
-
-func WithPackageName(ctx context.Context, name string) context.Context {
- return context.WithValue(ctx, contextkeys.PackageNameKey, name)
-}
-
-func WithStatusCode(ctx context.Context, code int) context.Context {
- return context.WithValue(ctx, contextkeys.StatusCodeKey, strconv.Itoa(code))
-}
-
-func WithResponseWriter(ctx context.Context, w http.ResponseWriter) context.Context {
- return context.WithValue(ctx, contextkeys.ResponseWriterKey, w)
-}
diff --git a/vendor/github.com/twitchtv/twirp/errors.go b/vendor/github.com/twitchtv/twirp/errors.go
deleted file mode 100644
index b9664b4..0000000
--- a/vendor/github.com/twitchtv/twirp/errors.go
+++ /dev/null
@@ -1,428 +0,0 @@
-// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may not
-// use this file except in compliance with the License. A copy of the License is
-// located at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// or in the "license" file accompanying this file. This file is distributed on
-// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-
-// Package twirp provides core types used in generated Twirp servers and client.
-//
-// Twirp services handle errors using the `twirp.Error` interface.
-//
-// For example, a server method may return an InvalidArgumentError:
-//
-// if req.Order != "DESC" && req.Order != "ASC" {
-// return nil, twirp.InvalidArgumentError("Order", "must be DESC or ASC")
-// }
-//
-// And the same twirp.Error is returned by the client, for example:
-//
-// resp, err := twirpClient.RPCMethod(ctx, req)
-// if err != nil {
-// if twerr, ok := err.(twirp.Error); ok {
-// switch twerr.Code() {
-// case twirp.InvalidArgument:
-// log.Error("invalid argument "+twirp.Meta("argument"))
-// default:
-// log.Error(twerr.Error())
-// }
-// }
-// }
-//
-// Clients may also return Internal errors if something failed on the system:
-// the server, the network, or the client itself (i.e. failure parsing
-// response).
-//
-package twirp
-
-import (
- "encoding/json"
- "errors"
- "fmt"
- "net/http"
- "strconv"
-)
-
-// Error represents an error in a Twirp service call.
-type Error interface {
- // Code is of the valid error codes.
- Code() ErrorCode
-
- // Msg returns a human-readable, unstructured messages describing the error.
- Msg() string
-
- // WithMeta returns a copy of the Error with the given key-value pair attached
- // as metadata. If the key is already set, it is overwritten.
- WithMeta(key string, val string) Error
-
- // Meta returns the stored value for the given key. If the key has no set
- // value, Meta returns an empty string. There is no way to distinguish between
- // an unset value and an explicit empty string.
- Meta(key string) string
-
- // MetaMap returns the complete key-value metadata map stored on the error.
- MetaMap() map[string]string
-
- // Error returns a string of the form "twirp error <Code>: <Msg>"
- Error() string
-}
-
-// code.Error(msg) builds a new Twirp error with code and msg. Example:
-// twirp.NotFound.Error("Resource not found")
-// twirp.Internal.Error("Oops")
-func (code ErrorCode) Error(msg string) Error {
- return NewError(code, msg)
-}
-
-// code.Errorf(msg, args...) builds a new Twirp error with code and formatted msg.
-// The format may include "%w" to wrap other errors. Examples:
-// twirp.Internal.Error("Oops: %w", originalErr)
-// twirp.NotFound.Error("Resource not found with id: %q", resourceID)
-func (code ErrorCode) Errorf(msgFmt string, a ...interface{}) Error {
- return NewErrorf(code, msgFmt, a...)
-}
-
-// WrapError allows Twirp errors to wrap other errors.
-// The wrapped error can be extracted later with (github.com/pkg/errors).Unwrap
-// or errors.Is from the standard errors package on Go 1.13+.
-func WrapError(twerr Error, err error) Error {
- return &wrappedErr{
- wrapper: twerr,
- cause: err,
- }
-}
-
-// NewError builds a twirp.Error. The code must be one of the valid predefined constants.
-// To add metadata, use .WithMeta(key, value) method after building the error.
-func NewError(code ErrorCode, msg string) Error {
- if !IsValidErrorCode(code) {
- return &twerr{code: Internal, msg: "invalid error type " + string(code)}
- }
- return &twerr{code: code, msg: msg}
-}
-
-// NewErrorf builds a twirp.Error with a formatted msg.
-// The format may include "%w" to wrap other errors. Examples:
-// twirp.NewErrorf(twirp.Internal, "Oops: %w", originalErr)
-// twirp.NewErrorf(twirp.NotFound, "resource with id: %q", resourceID)
-func NewErrorf(code ErrorCode, msgFmt string, a ...interface{}) Error {
- err := fmt.Errorf(msgFmt, a...) // format error message, may include "%w" with an original error
- twerr := NewError(code, err.Error()) // use the error as msg
- return WrapError(twerr, err) // wrap so the original error can be identified with errors.Is
-}
-
-// NotFoundError is a convenience constructor for NotFound errors.
-func NotFoundError(msg string) Error {
- return NewError(NotFound, msg)
-}
-
-// InvalidArgumentError is a convenience constructor for InvalidArgument errors.
-// The argument name is included on the "argument" metadata for convenience.
-func InvalidArgumentError(argument string, validationMsg string) Error {
- err := NewError(InvalidArgument, argument+" "+validationMsg)
- err = err.WithMeta("argument", argument)
- return err
-}
-
-// RequiredArgumentError builds an InvalidArgument error.
-// Useful when a request argument is expected to have a non-zero value.
-func RequiredArgumentError(argument string) Error {
- return InvalidArgumentError(argument, "is required")
-}
-
-// InternalError is a convenience constructor for Internal errors.
-func InternalError(msg string) Error {
- return NewError(Internal, msg)
-}
-
-// InternalErrorf uses the formatted message as the internal error msg.
-// The format may include "%w" to wrap other errors. Examples:
-// twirp.InternalErrorf("database error: %w", err)
-// twirp.InternalErrorf("failed to load resource %q: %w", resourceID, originalErr)
-func InternalErrorf(msgFmt string, a ...interface{}) Error {
- return NewErrorf(Internal, msgFmt, a...)
-}
-
-// InternalErrorWith makes an internal error, wrapping the original error and using it
-// for the error message, and with metadata "cause" with the original error type.
-// This function is used by Twirp services to wrap non-Twirp errors as internal errors.
-// The wrapped error can be extracted later with (github.com/pkg/errors).Unwrap
-// or errors.Is from the standard errors package on Go 1.13+.
-func InternalErrorWith(err error) Error {
- twerr := NewError(Internal, err.Error())
- twerr = twerr.WithMeta("cause", fmt.Sprintf("%T", err)) // to easily tell apart wrapped internal errors from explicit ones
- return WrapError(twerr, err)
-}
-
-// ErrorCode represents a Twirp error type.
-type ErrorCode string
-
-// Valid Twirp error types. Most error types are equivalent to gRPC status codes
-// and follow the same semantics.
-const (
- // Canceled indicates the operation was cancelled (typically by the caller).
- Canceled ErrorCode = "canceled"
-
- // Unknown error. For example when handling errors raised by APIs that do not
- // return enough error information.
- Unknown ErrorCode = "unknown"
-
- // InvalidArgument indicates client specified an invalid argument. It
- // indicates arguments that are problematic regardless of the state of the
- // system (i.e. a malformed file name, required argument, number out of range,
- // etc.).
- InvalidArgument ErrorCode = "invalid_argument"
-
- // Malformed indicates an error occurred while decoding the client's request.
- // This may mean that the message was encoded improperly, or that there is a
- // disagreement in message format between the client and server.
- Malformed ErrorCode = "malformed"
-
- // DeadlineExceeded means operation expired before completion. For operations
- // that change the state of the system, this error may be returned even if the
- // operation has completed successfully (timeout).
- DeadlineExceeded ErrorCode = "deadline_exceeded"
-
- // NotFound means some requested entity was not found.
- NotFound ErrorCode = "not_found"
-
- // BadRoute means that the requested URL path wasn't routable to a Twirp
- // service and method. This is returned by the generated server, and usually
- // shouldn't be returned by applications. Instead, applications should use
- // NotFound or Unimplemented.
- BadRoute ErrorCode = "bad_route"
-
- // AlreadyExists means an attempt to create an entity failed because one
- // already exists.
- AlreadyExists ErrorCode = "already_exists"
-
- // PermissionDenied indicates the caller does not have permission to execute
- // the specified operation. It must not be used if the caller cannot be
- // identified (Unauthenticated).
- PermissionDenied ErrorCode = "permission_denied"
-
- // Unauthenticated indicates the request does not have valid authentication
- // credentials for the operation.
- Unauthenticated ErrorCode = "unauthenticated"
-
- // ResourceExhausted indicates some resource has been exhausted or rate-limited,
- // perhaps a per-user quota, or perhaps the entire file system is out of space.
- ResourceExhausted ErrorCode = "resource_exhausted"
-
- // FailedPrecondition indicates operation was rejected because the system is
- // not in a state required for the operation's execution. For example, doing
- // an rmdir operation on a directory that is non-empty, or on a non-directory
- // object, or when having conflicting read-modify-write on the same resource.
- FailedPrecondition ErrorCode = "failed_precondition"
-
- // Aborted indicates the operation was aborted, typically due to a concurrency
- // issue like sequencer check failures, transaction aborts, etc.
- Aborted ErrorCode = "aborted"
-
- // OutOfRange means operation was attempted past the valid range. For example,
- // seeking or reading past end of a paginated collection.
- //
- // Unlike InvalidArgument, this error indicates a problem that may be fixed if
- // the system state changes (i.e. adding more items to the collection).
- //
- // There is a fair bit of overlap between FailedPrecondition and OutOfRange.
- // We recommend using OutOfRange (the more specific error) when it applies so
- // that callers who are iterating through a space can easily look for an
- // OutOfRange error to detect when they are done.
- OutOfRange ErrorCode = "out_of_range"
-
- // Unimplemented indicates operation is not implemented or not
- // supported/enabled in this service.
- Unimplemented ErrorCode = "unimplemented"
-
- // Internal errors. When some invariants expected by the underlying system
- // have been broken. In other words, something bad happened in the library or
- // backend service. Do not confuse with HTTP Internal Server Error; an
- // Internal error could also happen on the client code, i.e. when parsing a
- // server response.
- Internal ErrorCode = "internal"
-
- // Unavailable indicates the service is currently unavailable. This is a most
- // likely a transient condition and may be corrected by retrying with a
- // backoff.
- Unavailable ErrorCode = "unavailable"
-
- // DataLoss indicates unrecoverable data loss or corruption.
- DataLoss ErrorCode = "data_loss"
-
- // NoError is the zero-value, is considered an empty error and should not be
- // used.
- NoError ErrorCode = ""
-)
-
-// ServerHTTPStatusFromErrorCode maps a Twirp error type into a similar HTTP
-// response status. It is used by the Twirp server handler to set the HTTP
-// response status code. Returns 0 if the ErrorCode is invalid.
-func ServerHTTPStatusFromErrorCode(code ErrorCode) int {
- switch code {
- case Canceled:
- return 408 // RequestTimeout
- case Unknown:
- return 500 // Internal Server Error
- case InvalidArgument:
- return 400 // BadRequest
- case Malformed:
- return 400 // BadRequest
- case DeadlineExceeded:
- return 408 // RequestTimeout
- case NotFound:
- return 404 // Not Found
- case BadRoute:
- return 404 // Not Found
- case AlreadyExists:
- return 409 // Conflict
- case PermissionDenied:
- return 403 // Forbidden
- case Unauthenticated:
- return 401 // Unauthorized
- case ResourceExhausted:
- return 429 // Too Many Requests
- case FailedPrecondition:
- return 412 // Precondition Failed
- case Aborted:
- return 409 // Conflict
- case OutOfRange:
- return 400 // Bad Request
- case Unimplemented:
- return 501 // Not Implemented
- case Internal:
- return 500 // Internal Server Error
- case Unavailable:
- return 503 // Service Unavailable
- case DataLoss:
- return 500 // Internal Server Error
- case NoError:
- return 200 // OK
- default:
- return 0 // Invalid!
- }
-}
-
-// IsValidErrorCode returns true if is one of the valid predefined constants.
-func IsValidErrorCode(code ErrorCode) bool {
- return ServerHTTPStatusFromErrorCode(code) != 0
-}
-
-// twirp.Error implementation
-type twerr struct {
- code ErrorCode
- msg string
- meta map[string]string
-}
-
-func (e *twerr) Code() ErrorCode { return e.code }
-func (e *twerr) Msg() string { return e.msg }
-
-func (e *twerr) Meta(key string) string {
- if e.meta != nil {
- return e.meta[key] // also returns "" if key is not in meta map
- }
- return ""
-}
-
-func (e *twerr) WithMeta(key string, value string) Error {
- newErr := &twerr{
- code: e.code,
- msg: e.msg,
- meta: make(map[string]string, len(e.meta)),
- }
- for k, v := range e.meta {
- newErr.meta[k] = v
- }
- newErr.meta[key] = value
- return newErr
-}
-
-func (e *twerr) MetaMap() map[string]string {
- return e.meta
-}
-
-func (e *twerr) Error() string {
- return fmt.Sprintf("twirp error %s: %s", e.code, e.msg)
-}
-
-// wrappedErr is the error returned by twirp.InternalErrorWith(err), which is used by clients.
-// Implements Unwrap() to allow go 1.13+ errors.Is/As checks,
-// and Cause() to allow (github.com/pkg/errors).Unwrap.
-type wrappedErr struct {
- wrapper Error
- cause error
-}
-
-func (e *wrappedErr) Code() ErrorCode { return e.wrapper.Code() }
-func (e *wrappedErr) Msg() string { return e.wrapper.Msg() }
-func (e *wrappedErr) Meta(key string) string { return e.wrapper.Meta(key) }
-func (e *wrappedErr) MetaMap() map[string]string { return e.wrapper.MetaMap() }
-func (e *wrappedErr) Error() string { return e.wrapper.Error() }
-func (e *wrappedErr) WithMeta(key string, val string) Error {
- return &wrappedErr{
- wrapper: e.wrapper.WithMeta(key, val),
- cause: e.cause,
- }
-}
-func (e *wrappedErr) Unwrap() error { return e.cause } // for go1.13 + errors.Is/As
-func (e *wrappedErr) Cause() error { return e.cause } // for github.com/pkg/errors
-
-// WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta).
-// Useful outside of the Twirp server (e.g. http middleware).
-// If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)
-func WriteError(resp http.ResponseWriter, err error) error {
- var twerr Error
- if !errors.As(err, &twerr) {
- twerr = InternalErrorWith(err)
- }
-
- statusCode := ServerHTTPStatusFromErrorCode(twerr.Code())
- respBody := marshalErrorToJSON(twerr)
-
- resp.Header().Set("Content-Type", "application/json") // Error responses are always JSON
- resp.Header().Set("Content-Length", strconv.Itoa(len(respBody)))
- resp.WriteHeader(statusCode) // set HTTP status code and send response
-
- _, writeErr := resp.Write(respBody)
- if writeErr != nil {
- return writeErr
- }
- return nil
-}
-
-// JSON serialization for errors
-type twerrJSON struct {
- Code string `json:"code"`
- Msg string `json:"msg"`
- Meta map[string]string `json:"meta,omitempty"`
-}
-
-// marshalErrorToJSON returns JSON from a twirp.Error, that can be used as HTTP error response body.
-// If serialization fails, it will use a descriptive Internal error instead.
-func marshalErrorToJSON(twerr Error) []byte {
- // make sure that msg is not too large
- msg := twerr.Msg()
- if len(msg) > 1e6 {
- msg = msg[:1e6]
- }
-
- tj := twerrJSON{
- Code: string(twerr.Code()),
- Msg: msg,
- Meta: twerr.MetaMap(),
- }
-
- buf, err := json.Marshal(&tj)
- if err != nil {
- buf = []byte("{\"type\": \"" + Internal + "\", \"msg\": \"There was an error but it could not be serialized into JSON\"}") // fallback
- }
-
- return buf
-}
diff --git a/vendor/github.com/twitchtv/twirp/interceptors.go b/vendor/github.com/twitchtv/twirp/interceptors.go
deleted file mode 100644
index 0a5cbcf..0000000
--- a/vendor/github.com/twitchtv/twirp/interceptors.go
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may not
-// use this file except in compliance with the License. A copy of the License is
-// located at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// or in the "license" file accompanying this file. This file is distributed on
-// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-package twirp
-
-import (
- "context"
-)
-
-// Interceptor is a form of middleware for Twirp requests, that can be installed on both
-// clients and servers. To intercept RPC calls in the client, use the option
-// `twirp.WithClientInterceptors` on the client constructor. To intercept RPC calls in the server,
-// use the option `twirp.WithServerInterceptors` on the server constructor.
-//
-// Just like http middleware, interceptors can mutate requests and responses.
-// This can enable some powerful integrations, but it should be used with much care
-// because it may result in code that is very hard to debug.
-//
-// Example of an interceptor that logs every request and response:
-//
-// func LogInterceptor(l *log.Logger) twirp.Interceptor {
-// return func(next twirp.Method) twirp.Method {
-// return func(ctx context.Context, req interface{}) (interface{}, error) {
-// l.Printf("Service: %s, Method: %s, Request: %v",
-// twirp.ServiceName(ctx), twirp.MethodName(ctx), req)
-// resp, err := next(ctx, req)
-// l.Printf("Response: %v, Error: %v", resp)
-// return resp, err
-// }
-// }
-// }
-//
-type Interceptor func(Method) Method
-
-// Method is a generic representation of a Twirp-generated RPC method.
-// It is used to define Interceptors.
-type Method func(ctx context.Context, request interface{}) (interface{}, error)
-
-// ChainInterceptors chains multiple Interceptors into a single Interceptor.
-// The first interceptor wraps the second one, and so on.
-// Returns nil if interceptors is empty. Nil interceptors are ignored.
-func ChainInterceptors(interceptors ...Interceptor) Interceptor {
- filtered := make([]Interceptor, 0, len(interceptors))
- for _, interceptor := range interceptors {
- if interceptor != nil {
- filtered = append(filtered, interceptor)
- }
- }
- switch n := len(filtered); n {
- case 0:
- return nil
- case 1:
- return filtered[0]
- default:
- first := filtered[0]
- return func(next Method) Method {
- for i := len(filtered) - 1; i > 0; i-- {
- next = filtered[i](next)
- }
- return first(next)
- }
- }
-}
diff --git a/vendor/github.com/twitchtv/twirp/internal/contextkeys/keys.go b/vendor/github.com/twitchtv/twirp/internal/contextkeys/keys.go
deleted file mode 100644
index e8c35bd..0000000
--- a/vendor/github.com/twitchtv/twirp/internal/contextkeys/keys.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may not
-// use this file except in compliance with the License. A copy of the License is
-// located at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// or in the "license" file accompanying this file. This file is distributed on
-// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-
-// Package contextkeys stores the keys to the context accessor
-// functions, letting generated code safely set values in contexts
-// without exposing the setters to the outside world.
-package contextkeys
-
-type contextKey int
-
-const (
- MethodNameKey contextKey = 1 + iota
- ServiceNameKey
- PackageNameKey
- StatusCodeKey
- RequestHeaderKey
- ResponseWriterKey
-)
diff --git a/vendor/github.com/twitchtv/twirp/logo.png b/vendor/github.com/twitchtv/twirp/logo.png
deleted file mode 100644
index c80f897..0000000
--- a/vendor/github.com/twitchtv/twirp/logo.png
+++ /dev/null
Binary files differ
diff --git a/vendor/github.com/twitchtv/twirp/server_options.go b/vendor/github.com/twitchtv/twirp/server_options.go
deleted file mode 100644
index 73798fc..0000000
--- a/vendor/github.com/twitchtv/twirp/server_options.go
+++ /dev/null
@@ -1,242 +0,0 @@
-// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may not
-// use this file except in compliance with the License. A copy of the License is
-// located at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// or in the "license" file accompanying this file. This file is distributed on
-// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-package twirp
-
-import (
- "context"
- "reflect"
-)
-
-// ServerOption is a functional option for extending a Twirp service.
-type ServerOption func(*ServerOptions)
-
-// WithServerHooks defines the hooks for a Twirp server.
-func WithServerHooks(hooks *ServerHooks) ServerOption {
- return func(opts *ServerOptions) {
- opts.Hooks = hooks
- }
-}
-
-// WithServerInterceptors defines the interceptors for a Twirp server.
-func WithServerInterceptors(interceptors ...Interceptor) ServerOption {
- return func(opts *ServerOptions) {
- opts.Interceptors = append(opts.Interceptors, interceptors...)
- }
-}
-
-// WithServerPathPrefix specifies a different prefix for routing.
-// If not specified, the "/twirp" prefix is used by default.
-// An empty value "" can be speficied to use no prefix.
-// The clients must be configured to send requests using the same prefix.
-// URL format: "<baseURL>[<prefix>]/<package>.<Service>/<Method>"
-// More info on Twirp docs: https://twitchtv.github.io/twirp/docs/routing.html
-func WithServerPathPrefix(prefix string) ServerOption {
- return func(opts *ServerOptions) {
- opts.setOpt("pathPrefix", prefix)
- opts.pathPrefix = &prefix // for code generated before v8.1.0
- }
-}
-
-// WithServerJSONSkipDefaults configures JSON serialization to skip
-// unpopulated or default values in JSON responses, which results in
-// smaller response sizes. This was the default before v7 and can be
-// enabled for full backwards compatibility if required.
-// This is now disabled by default, because JSON serialization is
-// commonly used for manual debugging, in which case it is useful
-// to see the full shape of the response.
-// See: https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson
-// See: https://developers.google.com/protocol-buffers/docs/proto3#json
-func WithServerJSONSkipDefaults(skipDefaults bool) ServerOption {
- return func(opts *ServerOptions) {
- opts.setOpt("jsonSkipDefaults", skipDefaults)
- opts.JSONSkipDefaults = skipDefaults // for code generated before v8.1.0
- }
-}
-
-// WithServerJSONCamelCaseNames configures JSON serialization to use the
-// default proto3 JSON encoding (lowerCamelCase) rather than the original
-// proto field names. Twirp uses the original proto field names by default,
-// because JSON encoding is often used for manual debugging of the API,
-// but this option allows better compatibility with other proto-json parsers.
-// See: https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson
-// See: https://developers.google.com/protocol-buffers/docs/proto3#json
-func WithServerJSONCamelCaseNames(jsonCamelCase bool) ServerOption {
- return func(opts *ServerOptions) {
- opts.setOpt("jsonCamelCase", jsonCamelCase)
- }
-}
-
-// ServerHooks is a container for callbacks that can instrument a
-// Twirp-generated server. These callbacks all accept a context and return a
-// context. They can use this to add to the request context as it threads
-// through the system, appending values or deadlines to it.
-//
-// The RequestReceived and RequestRouted hooks are special: they can return
-// errors. If they return a non-nil error, handling for that request will be
-// stopped at that point. The Error hook will be triggered, and the error will
-// be sent to the client. This can be used for stuff like auth checks before
-// deserializing a request.
-//
-// The RequestReceived hook is always called first, and it is called for every
-// request that the Twirp server handles. The last hook to be called in a
-// request's lifecycle is always ResponseSent, even in the case of an error.
-//
-// Details on the timing of each hook are documented as comments on the fields
-// of the ServerHooks type.
-type ServerHooks struct {
- // RequestReceived is called as soon as a request enters the Twirp
- // server at the earliest available moment.
- RequestReceived func(context.Context) (context.Context, error)
-
- // RequestRouted is called when a request has been routed to a
- // particular method of the Twirp server.
- RequestRouted func(context.Context) (context.Context, error)
-
- // ResponsePrepared is called when a request has been handled and a
- // response is ready to be sent to the client.
- ResponsePrepared func(context.Context) context.Context
-
- // ResponseSent is called when all bytes of a response (including an error
- // response) have been written. Because the ResponseSent hook is terminal, it
- // does not return a context.
- ResponseSent func(context.Context)
-
- // Error hook is called when an error occurs while handling a request. The
- // Error is passed as argument to the hook.
- Error func(context.Context, Error) context.Context
-}
-
-// ChainHooks creates a new *ServerHooks which chains the callbacks in
-// each of the constituent hooks passed in. Each hook function will be
-// called in the order of the ServerHooks values passed in.
-//
-// For the erroring hooks, RequestReceived and RequestRouted, any returned
-// errors prevent processing by later hooks.
-func ChainHooks(hooks ...*ServerHooks) *ServerHooks {
- if len(hooks) == 0 {
- return nil
- }
- if len(hooks) == 1 {
- return hooks[0]
- }
- return &ServerHooks{
- RequestReceived: func(ctx context.Context) (context.Context, error) {
- var err error
- for _, h := range hooks {
- if h != nil && h.RequestReceived != nil {
- ctx, err = h.RequestReceived(ctx)
- if err != nil {
- return ctx, err
- }
- }
- }
- return ctx, nil
- },
- RequestRouted: func(ctx context.Context) (context.Context, error) {
- var err error
- for _, h := range hooks {
- if h != nil && h.RequestRouted != nil {
- ctx, err = h.RequestRouted(ctx)
- if err != nil {
- return ctx, err
- }
- }
- }
- return ctx, nil
- },
- ResponsePrepared: func(ctx context.Context) context.Context {
- for _, h := range hooks {
- if h != nil && h.ResponsePrepared != nil {
- ctx = h.ResponsePrepared(ctx)
- }
- }
- return ctx
- },
- ResponseSent: func(ctx context.Context) {
- for _, h := range hooks {
- if h != nil && h.ResponseSent != nil {
- h.ResponseSent(ctx)
- }
- }
- },
- Error: func(ctx context.Context, twerr Error) context.Context {
- for _, h := range hooks {
- if h != nil && h.Error != nil {
- ctx = h.Error(ctx, twerr)
- }
- }
- return ctx
- },
- }
-}
-
-// ServerOptions encapsulate the configurable parameters on a Twirp server.
-// This type is meant to be used only by generated code.
-type ServerOptions struct {
- // Untyped options map. The methods setOpt and ReadOpt are used to set
- // and read options. The options are untyped so when a new option is added,
- // newly generated code can still work with older versions of the runtime.
- m map[string]interface{}
-
- Hooks *ServerHooks
- Interceptors []Interceptor
-
- // Properties below are only used by code that was
- // generated by older versions of Twirp (before v8.1.0).
- // New options with standard types added in the future
- // don't need new properties, they should use ReadOpt.
- JSONSkipDefaults bool
- pathPrefix *string
-}
-
-// ReadOpt extracts an option to a pointer value,
-// returns true if the option exists and was extracted.
-// This method is meant to be used by generated code,
-// keeping the type dependency outside of the runtime.
-//
-// Usage example:
-//
-// opts.setOpt("fooOpt", 123)
-// var foo int
-// ok := opts.ReadOpt("fooOpt", &int)
-//
-func (opts *ServerOptions) ReadOpt(key string, out interface{}) bool {
- val, ok := opts.m[key]
- if !ok {
- return false
- }
-
- rout := reflect.ValueOf(out)
- if rout.Kind() != reflect.Ptr {
- panic("ReadOpt(key, out); out must be a pointer but it was not")
- }
- rout.Elem().Set(reflect.ValueOf(val))
- return true
-}
-
-// setOpt adds an option key/value. It is used by ServerOption helpers.
-// The value can be extracted with ReadOpt by passing a pointer to the same type.
-func (opts *ServerOptions) setOpt(key string, val interface{}) {
- if opts.m == nil {
- opts.m = make(map[string]interface{})
- }
- opts.m[key] = val
-}
-
-// PathPrefix() is used only by clients generated before v8.1.0
-func (opts *ServerOptions) PathPrefix() string {
- if opts.pathPrefix == nil {
- return "/twirp" // default prefix
- }
- return *opts.pathPrefix
-}
diff --git a/vendor/github.com/twitchtv/twirp/tools.json b/vendor/github.com/twitchtv/twirp/tools.json
deleted file mode 100644
index d0aa577..0000000
--- a/vendor/github.com/twitchtv/twirp/tools.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "Tools": [
- {
- "Repository": "github.com/kisielk/errcheck",
- "Commit": "db0ca22445717d1b2c51ac1034440e0a2a2de645"
- },
- {
- "Repository": "github.com/twitchtv/retool",
- "Commit": "6f6d4930d88c40e23d2b54d12e64f0444e1fb4ef"
- },
- {
- "Repository": "google.golang.org/protobuf/cmd/protoc-gen-go",
- "Commit": "fc9592f7ac4bade8f83e636263f8f07715c698d1"
- }
- ],
- "RetoolVersion": "1.3.5"
-} \ No newline at end of file
diff --git a/vendor/github.com/twitchtv/twirp/version_constant.go b/vendor/github.com/twitchtv/twirp/version_constant.go
deleted file mode 100644
index 5e305aa..0000000
--- a/vendor/github.com/twitchtv/twirp/version_constant.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"). You may not
-// use this file except in compliance with the License. A copy of the License is
-// located at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// or in the "license" file accompanying this file. This file is distributed on
-// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-// express or implied. See the License for the specific language governing
-// permissions and limitations under the License.
-
-package twirp
-
-// TwirpPackageIsVersion7 is a constant referenced from generated code to
-// assert version compatibility at compile time.
-const TwirpPackageIsVersion7 = true
-
-// TwirpPackageMinVersion_8_1_0 is required from generated code to
-// assert version compatibility at compile time.
-const TwirpPackageMinVersion_8_1_0 = true
diff --git a/vendor/github.com/xlgmokha/x/pkg/x/error.go b/vendor/github.com/xlgmokha/x/pkg/x/error.go
index be9db9c..2f0a5f3 100644
--- a/vendor/github.com/xlgmokha/x/pkg/x/error.go
+++ b/vendor/github.com/xlgmokha/x/pkg/x/error.go
@@ -14,3 +14,7 @@ func Must[T any](item T, err error) T {
Check(err)
return item
}
+
+func Try[T any](item T, _err error) T {
+ return item
+}