File
Blob: spec/protocol/client_query.twirp.go
| 1 | // Code generated by protoc-gen-twirp v8.1.3, DO NOT EDIT. |
| 2 | // source: spec/proto/client_query.proto |
| 3 | |
| 4 | package protocol |
| 5 | |
| 6 | import context "context" |
| 7 | import fmt "fmt" |
| 8 | import http "net/http" |
| 9 | import io "io" |
| 10 | import json "encoding/json" |
| 11 | import strconv "strconv" |
| 12 | import strings "strings" |
| 13 | |
| 14 | import protojson "google.golang.org/protobuf/encoding/protojson" |
| 15 | import twirp "github.com/twitchtv/twirp" |
| 16 | import ctxsetters "github.com/twitchtv/twirp/ctxsetters" |
| 17 | |
| 18 | // Version compatibility assertion. |
| 19 | // If the constant is not defined in the package, that likely means |
| 20 | // the package needs to be updated to work with this generated code. |
| 21 | // See https://twitchtv.github.io/twirp/docs/version_matrix.html |
| 22 | const _ = twirp.TwirpPackageMinVersion_8_1_0 |
| 23 | |
| 24 | // ============================ |
| 25 | // ClientQueryService Interface |
| 26 | // ============================ |
| 27 | |
| 28 | type ClientQueryService interface { |
| 29 | ListTunnels(context.Context, *ListTunnelsRequest) (*ListTunnelsResponse, error) |
| 30 | } |
| 31 | |
| 32 | // ================================== |
| 33 | // ClientQueryService Protobuf Client |
| 34 | // ================================== |
| 35 | |
| 36 | type clientQueryServiceProtobufClient struct { |
| 37 | client HTTPClient |
| 38 | urls [1]string |
| 39 | interceptor twirp.Interceptor |
| 40 | opts twirp.ClientOptions |
| 41 | } |
| 42 | |
| 43 | // NewClientQueryServiceProtobufClient creates a Protobuf client that implements the ClientQueryService interface. |
| 44 | // It communicates using Protobuf and can be configured with a custom HTTPClient. |
| 45 | func NewClientQueryServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) ClientQueryService { |
| 46 | if c, ok := client.(*http.Client); ok { |
| 47 | client = withoutRedirects(c) |
| 48 | } |
| 49 | |
| 50 | clientOpts := twirp.ClientOptions{} |
| 51 | for _, o := range opts { |
| 52 | o(&clientOpts) |
| 53 | } |
| 54 | |
| 55 | // Using ReadOpt allows backwards and forwards compatibility with new options in the future |
| 56 | literalURLs := false |
| 57 | _ = clientOpts.ReadOpt("literalURLs", &literalURLs) |
| 58 | var pathPrefix string |
| 59 | if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { |
| 60 | pathPrefix = "/twirp" // default prefix |
| 61 | } |
| 62 | |
| 63 | // Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method> |
| 64 | serviceURL := sanitizeBaseURL(baseURL) |
| 65 | serviceURL += baseServicePath(pathPrefix, "protocol", "ClientQueryService") |
| 66 | urls := [1]string{ |
| 67 | serviceURL + "ListTunnels", |
| 68 | } |
| 69 | |
| 70 | return &clientQueryServiceProtobufClient{ |
| 71 | client: client, |
| 72 | urls: urls, |
| 73 | interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), |
| 74 | opts: clientOpts, |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func (c *clientQueryServiceProtobufClient) ListTunnels(ctx context.Context, in *ListTunnelsRequest) (*ListTunnelsResponse, error) { |
| 79 | ctx = ctxsetters.WithPackageName(ctx, "protocol") |
| 80 | ctx = ctxsetters.WithServiceName(ctx, "ClientQueryService") |
| 81 | ctx = ctxsetters.WithMethodName(ctx, "ListTunnels") |
| 82 | caller := c.callListTunnels |
| 83 | if c.interceptor != nil { |
| 84 | caller = func(ctx context.Context, req *ListTunnelsRequest) (*ListTunnelsResponse, error) { |
| 85 | resp, err := c.interceptor( |
| 86 | func(ctx context.Context, req interface{}) (interface{}, error) { |
| 87 | typedReq, ok := req.(*ListTunnelsRequest) |
| 88 | if !ok { |
| 89 | return nil, twirp.InternalError("failed type assertion req.(*ListTunnelsRequest) when calling interceptor") |
| 90 | } |
| 91 | return c.callListTunnels(ctx, typedReq) |
| 92 | }, |
| 93 | )(ctx, req) |
| 94 | if resp != nil { |
| 95 | typedResp, ok := resp.(*ListTunnelsResponse) |
| 96 | if !ok { |
| 97 | return nil, twirp.InternalError("failed type assertion resp.(*ListTunnelsResponse) when calling interceptor") |
| 98 | } |
| 99 | return typedResp, err |
| 100 | } |
| 101 | return nil, err |
| 102 | } |
| 103 | } |
| 104 | return caller(ctx, in) |
| 105 | } |
| 106 | |
| 107 | func (c *clientQueryServiceProtobufClient) callListTunnels(ctx context.Context, in *ListTunnelsRequest) (*ListTunnelsResponse, error) { |
| 108 | out := new(ListTunnelsResponse) |
| 109 | ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) |
| 110 | if err != nil { |
| 111 | twerr, ok := err.(twirp.Error) |
| 112 | if !ok { |
| 113 | twerr = twirp.InternalErrorWith(err) |
| 114 | } |
| 115 | callClientError(ctx, c.opts.Hooks, twerr) |
| 116 | return nil, err |
| 117 | } |
| 118 | |
| 119 | callClientResponseReceived(ctx, c.opts.Hooks) |
| 120 | |
| 121 | return out, nil |
| 122 | } |
| 123 | |
| 124 | // ============================== |
| 125 | // ClientQueryService JSON Client |
| 126 | // ============================== |
| 127 | |
| 128 | type clientQueryServiceJSONClient struct { |
| 129 | client HTTPClient |
| 130 | urls [1]string |
| 131 | interceptor twirp.Interceptor |
| 132 | opts twirp.ClientOptions |
| 133 | } |
| 134 | |
| 135 | // NewClientQueryServiceJSONClient creates a JSON client that implements the ClientQueryService interface. |
| 136 | // It communicates using JSON and can be configured with a custom HTTPClient. |
| 137 | func NewClientQueryServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) ClientQueryService { |
| 138 | if c, ok := client.(*http.Client); ok { |
| 139 | client = withoutRedirects(c) |
| 140 | } |
| 141 | |
| 142 | clientOpts := twirp.ClientOptions{} |
| 143 | for _, o := range opts { |
| 144 | o(&clientOpts) |
| 145 | } |
| 146 | |
| 147 | // Using ReadOpt allows backwards and forwards compatibility with new options in the future |
| 148 | literalURLs := false |
| 149 | _ = clientOpts.ReadOpt("literalURLs", &literalURLs) |
| 150 | var pathPrefix string |
| 151 | if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { |
| 152 | pathPrefix = "/twirp" // default prefix |
| 153 | } |
| 154 | |
| 155 | // Build method URLs: <baseURL>[<prefix>]/<package>.<Service>/<Method> |
| 156 | serviceURL := sanitizeBaseURL(baseURL) |
| 157 | serviceURL += baseServicePath(pathPrefix, "protocol", "ClientQueryService") |
| 158 | urls := [1]string{ |
| 159 | serviceURL + "ListTunnels", |
| 160 | } |
| 161 | |
| 162 | return &clientQueryServiceJSONClient{ |
| 163 | client: client, |
| 164 | urls: urls, |
| 165 | interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), |
| 166 | opts: clientOpts, |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | func (c *clientQueryServiceJSONClient) ListTunnels(ctx context.Context, in *ListTunnelsRequest) (*ListTunnelsResponse, error) { |
| 171 | ctx = ctxsetters.WithPackageName(ctx, "protocol") |
| 172 | ctx = ctxsetters.WithServiceName(ctx, "ClientQueryService") |
| 173 | ctx = ctxsetters.WithMethodName(ctx, "ListTunnels") |
| 174 | caller := c.callListTunnels |
| 175 | if c.interceptor != nil { |
| 176 | caller = func(ctx context.Context, req *ListTunnelsRequest) (*ListTunnelsResponse, error) { |
| 177 | resp, err := c.interceptor( |
| 178 | func(ctx context.Context, req interface{}) (interface{}, error) { |
| 179 | typedReq, ok := req.(*ListTunnelsRequest) |
| 180 | if !ok { |
| 181 | return nil, twirp.InternalError("failed type assertion req.(*ListTunnelsRequest) when calling interceptor") |
| 182 | } |
| 183 | return c.callListTunnels(ctx, typedReq) |
| 184 | }, |
| 185 | )(ctx, req) |
| 186 | if resp != nil { |
| 187 | typedResp, ok := resp.(*ListTunnelsResponse) |
| 188 | if !ok { |
| 189 | return nil, twirp.InternalError("failed type assertion resp.(*ListTunnelsResponse) when calling interceptor") |
| 190 | } |
| 191 | return typedResp, err |
| 192 | } |
| 193 | return nil, err |
| 194 | } |
| 195 | } |
| 196 | return caller(ctx, in) |
| 197 | } |
| 198 | |
| 199 | func (c *clientQueryServiceJSONClient) callListTunnels(ctx context.Context, in *ListTunnelsRequest) (*ListTunnelsResponse, error) { |
| 200 | out := new(ListTunnelsResponse) |
| 201 | ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) |
| 202 | if err != nil { |
| 203 | twerr, ok := err.(twirp.Error) |
| 204 | if !ok { |
| 205 | twerr = twirp.InternalErrorWith(err) |
| 206 | } |
| 207 | callClientError(ctx, c.opts.Hooks, twerr) |
| 208 | return nil, err |
| 209 | } |
| 210 | |
| 211 | callClientResponseReceived(ctx, c.opts.Hooks) |
| 212 | |
| 213 | return out, nil |
| 214 | } |
| 215 | |
| 216 | // ================================= |
| 217 | // ClientQueryService Server Handler |
| 218 | // ================================= |
| 219 | |
| 220 | type clientQueryServiceServer struct { |
| 221 | ClientQueryService |
| 222 | interceptor twirp.Interceptor |
| 223 | hooks *twirp.ServerHooks |
| 224 | pathPrefix string // prefix for routing |
| 225 | jsonSkipDefaults bool // do not include unpopulated fields (default values) in the response |
| 226 | jsonCamelCase bool // JSON fields are serialized as lowerCamelCase rather than keeping the original proto names |
| 227 | } |
| 228 | |
| 229 | // NewClientQueryServiceServer builds a TwirpServer that can be used as an http.Handler to handle |
| 230 | // HTTP requests that are routed to the right method in the provided svc implementation. |
| 231 | // The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks). |
| 232 | func NewClientQueryServiceServer(svc ClientQueryService, opts ...interface{}) TwirpServer { |
| 233 | serverOpts := newServerOpts(opts) |
| 234 | |
| 235 | // Using ReadOpt allows backwards and forwards compatibility with new options in the future |
| 236 | jsonSkipDefaults := false |
| 237 | _ = serverOpts.ReadOpt("jsonSkipDefaults", &jsonSkipDefaults) |
| 238 | jsonCamelCase := false |
| 239 | _ = serverOpts.ReadOpt("jsonCamelCase", &jsonCamelCase) |
| 240 | var pathPrefix string |
| 241 | if ok := serverOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { |
| 242 | pathPrefix = "/twirp" // default prefix |
| 243 | } |
| 244 | |
| 245 | return &clientQueryServiceServer{ |
| 246 | ClientQueryService: svc, |
| 247 | hooks: serverOpts.Hooks, |
| 248 | interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...), |
| 249 | pathPrefix: pathPrefix, |
| 250 | jsonSkipDefaults: jsonSkipDefaults, |
| 251 | jsonCamelCase: jsonCamelCase, |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | // writeError writes an HTTP response with a valid Twirp error format, and triggers hooks. |
| 256 | // If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) |
| 257 | func (s *clientQueryServiceServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) { |
| 258 | writeError(ctx, resp, err, s.hooks) |
| 259 | } |
| 260 | |
| 261 | // handleRequestBodyError is used to handle error when the twirp server cannot read request |
| 262 | func (s *clientQueryServiceServer) handleRequestBodyError(ctx context.Context, resp http.ResponseWriter, msg string, err error) { |
| 263 | if context.Canceled == ctx.Err() { |
| 264 | s.writeError(ctx, resp, twirp.NewError(twirp.Canceled, "failed to read request: context canceled")) |
| 265 | return |
| 266 | } |
| 267 | if context.DeadlineExceeded == ctx.Err() { |
| 268 | s.writeError(ctx, resp, twirp.NewError(twirp.DeadlineExceeded, "failed to read request: deadline exceeded")) |
| 269 | return |
| 270 | } |
| 271 | s.writeError(ctx, resp, twirp.WrapError(malformedRequestError(msg), err)) |
| 272 | } |
| 273 | |
| 274 | // ClientQueryServicePathPrefix is a convenience constant that may identify URL paths. |
| 275 | // Should be used with caution, it only matches routes generated by Twirp Go clients, |
| 276 | // with the default "/twirp" prefix and default CamelCase service and method names. |
| 277 | // More info: https://twitchtv.github.io/twirp/docs/routing.html |
| 278 | const ClientQueryServicePathPrefix = "/twirp/protocol.ClientQueryService/" |
| 279 | |
| 280 | func (s *clientQueryServiceServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { |
| 281 | ctx := req.Context() |
| 282 | ctx = ctxsetters.WithPackageName(ctx, "protocol") |
| 283 | ctx = ctxsetters.WithServiceName(ctx, "ClientQueryService") |
| 284 | ctx = ctxsetters.WithResponseWriter(ctx, resp) |
| 285 | |
| 286 | var err error |
| 287 | ctx, err = callRequestReceived(ctx, s.hooks) |
| 288 | if err != nil { |
| 289 | s.writeError(ctx, resp, err) |
| 290 | return |
| 291 | } |
| 292 | |
| 293 | if req.Method != "POST" { |
| 294 | msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method) |
| 295 | s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) |
| 296 | return |
| 297 | } |
| 298 | |
| 299 | // Verify path format: [<prefix>]/<package>.<Service>/<Method> |
| 300 | prefix, pkgService, method := parseTwirpPath(req.URL.Path) |
| 301 | if pkgService != "protocol.ClientQueryService" { |
| 302 | msg := fmt.Sprintf("no handler for path %q", req.URL.Path) |
| 303 | s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) |
| 304 | return |
| 305 | } |
| 306 | if prefix != s.pathPrefix { |
| 307 | msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path) |
| 308 | s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) |
| 309 | return |
| 310 | } |
| 311 | |
| 312 | switch method { |
| 313 | case "ListTunnels": |
| 314 | s.serveListTunnels(ctx, resp, req) |
| 315 | return |
| 316 | default: |
| 317 | msg := fmt.Sprintf("no handler for path %q", req.URL.Path) |
| 318 | s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) |
| 319 | return |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | func (s *clientQueryServiceServer) serveListTunnels(ctx context.Context, resp http.ResponseWriter, req *http.Request) { |
| 324 | header := req.Header.Get("Content-Type") |
| 325 | i := strings.Index(header, ";") |
| 326 | if i == -1 { |
| 327 | i = len(header) |
| 328 | } |
| 329 | switch strings.TrimSpace(strings.ToLower(header[:i])) { |
| 330 | case "application/json": |
| 331 | s.serveListTunnelsJSON(ctx, resp, req) |
| 332 | case "application/protobuf": |
| 333 | s.serveListTunnelsProtobuf(ctx, resp, req) |
| 334 | default: |
| 335 | msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) |
| 336 | twerr := badRouteError(msg, req.Method, req.URL.Path) |
| 337 | s.writeError(ctx, resp, twerr) |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | func (s *clientQueryServiceServer) serveListTunnelsJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { |
| 342 | var err error |
| 343 | ctx = ctxsetters.WithMethodName(ctx, "ListTunnels") |
| 344 | ctx, err = callRequestRouted(ctx, s.hooks) |
| 345 | if err != nil { |
| 346 | s.writeError(ctx, resp, err) |
| 347 | return |
| 348 | } |
| 349 | |
| 350 | d := json.NewDecoder(req.Body) |
| 351 | rawReqBody := json.RawMessage{} |
| 352 | if err := d.Decode(&rawReqBody); err != nil { |
| 353 | s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) |
| 354 | return |
| 355 | } |
| 356 | reqContent := new(ListTunnelsRequest) |
| 357 | unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} |
| 358 | if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { |
| 359 | s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) |
| 360 | return |
| 361 | } |
| 362 | |
| 363 | handler := s.ClientQueryService.ListTunnels |
| 364 | if s.interceptor != nil { |
| 365 | handler = func(ctx context.Context, req *ListTunnelsRequest) (*ListTunnelsResponse, error) { |
| 366 | resp, err := s.interceptor( |
| 367 | func(ctx context.Context, req interface{}) (interface{}, error) { |
| 368 | typedReq, ok := req.(*ListTunnelsRequest) |
| 369 | if !ok { |
| 370 | return nil, twirp.InternalError("failed type assertion req.(*ListTunnelsRequest) when calling interceptor") |
| 371 | } |
| 372 | return s.ClientQueryService.ListTunnels(ctx, typedReq) |
| 373 | }, |
| 374 | )(ctx, req) |
| 375 | if resp != nil { |
| 376 | typedResp, ok := resp.(*ListTunnelsResponse) |
| 377 | if !ok { |
| 378 | return nil, twirp.InternalError("failed type assertion resp.(*ListTunnelsResponse) when calling interceptor") |
| 379 | } |
| 380 | return typedResp, err |
| 381 | } |
| 382 | return nil, err |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | // Call service method |
| 387 | var respContent *ListTunnelsResponse |
| 388 | func() { |
| 389 | defer ensurePanicResponses(ctx, resp, s.hooks) |
| 390 | respContent, err = handler(ctx, reqContent) |
| 391 | }() |
| 392 | |
| 393 | if err != nil { |
| 394 | s.writeError(ctx, resp, err) |
| 395 | return |
| 396 | } |
| 397 | if respContent == nil { |
| 398 | s.writeError(ctx, resp, twirp.InternalError("received a nil *ListTunnelsResponse and nil error while calling ListTunnels. nil responses are not supported")) |
| 399 | return |
| 400 | } |
| 401 | |
| 402 | ctx = callResponsePrepared(ctx, s.hooks) |
| 403 | |
| 404 | marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} |
| 405 | respBytes, err := marshaler.Marshal(respContent) |
| 406 | if err != nil { |
| 407 | s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) |
| 408 | return |
| 409 | } |
| 410 | |
| 411 | ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) |
| 412 | resp.Header().Set("Content-Type", "application/json") |
| 413 | resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) |
| 414 | resp.WriteHeader(http.StatusOK) |
| 415 | |
| 416 | if n, err := resp.Write(respBytes); err != nil { |
| 417 | msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) |
| 418 | twerr := twirp.NewError(twirp.Unknown, msg) |
| 419 | ctx = callError(ctx, s.hooks, twerr) |
| 420 | } |
| 421 | callResponseSent(ctx, s.hooks) |
| 422 | } |
| 423 | |
| 424 | func (s *clientQueryServiceServer) serveListTunnelsProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { |
| 425 | var err error |
| 426 | ctx = ctxsetters.WithMethodName(ctx, "ListTunnels") |
| 427 | ctx, err = callRequestRouted(ctx, s.hooks) |
| 428 | if err != nil { |
| 429 | s.writeError(ctx, resp, err) |
| 430 | return |
| 431 | } |
| 432 | |
| 433 | buf, err := io.ReadAll(req.Body) |
| 434 | if err != nil { |
| 435 | s.handleRequestBodyError(ctx, resp, "failed to read request body", err) |
| 436 | return |
| 437 | } |
| 438 | reqContent := new(ListTunnelsRequest) |
| 439 | if err = reqContent.UnmarshalVT(buf); err != nil { |
| 440 | s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) |
| 441 | return |
| 442 | } |
| 443 | |
| 444 | handler := s.ClientQueryService.ListTunnels |
| 445 | if s.interceptor != nil { |
| 446 | handler = func(ctx context.Context, req *ListTunnelsRequest) (*ListTunnelsResponse, error) { |
| 447 | resp, err := s.interceptor( |
| 448 | func(ctx context.Context, req interface{}) (interface{}, error) { |
| 449 | typedReq, ok := req.(*ListTunnelsRequest) |
| 450 | if !ok { |
| 451 | return nil, twirp.InternalError("failed type assertion req.(*ListTunnelsRequest) when calling interceptor") |
| 452 | } |
| 453 | return s.ClientQueryService.ListTunnels(ctx, typedReq) |
| 454 | }, |
| 455 | )(ctx, req) |
| 456 | if resp != nil { |
| 457 | typedResp, ok := resp.(*ListTunnelsResponse) |
| 458 | if !ok { |
| 459 | return nil, twirp.InternalError("failed type assertion resp.(*ListTunnelsResponse) when calling interceptor") |
| 460 | } |
| 461 | return typedResp, err |
| 462 | } |
| 463 | return nil, err |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | // Call service method |
| 468 | var respContent *ListTunnelsResponse |
| 469 | func() { |
| 470 | defer ensurePanicResponses(ctx, resp, s.hooks) |
| 471 | respContent, err = handler(ctx, reqContent) |
| 472 | }() |
| 473 | |
| 474 | if err != nil { |
| 475 | s.writeError(ctx, resp, err) |
| 476 | return |
| 477 | } |
| 478 | if respContent == nil { |
| 479 | s.writeError(ctx, resp, twirp.InternalError("received a nil *ListTunnelsResponse and nil error while calling ListTunnels. nil responses are not supported")) |
| 480 | return |
| 481 | } |
| 482 | |
| 483 | ctx = callResponsePrepared(ctx, s.hooks) |
| 484 | |
| 485 | respBytes, err := respContent.MarshalVT() |
| 486 | if err != nil { |
| 487 | s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) |
| 488 | return |
| 489 | } |
| 490 | |
| 491 | ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) |
| 492 | resp.Header().Set("Content-Type", "application/protobuf") |
| 493 | resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) |
| 494 | resp.WriteHeader(http.StatusOK) |
| 495 | if n, err := resp.Write(respBytes); err != nil { |
| 496 | msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) |
| 497 | twerr := twirp.NewError(twirp.Unknown, msg) |
| 498 | ctx = callError(ctx, s.hooks, twerr) |
| 499 | } |
| 500 | callResponseSent(ctx, s.hooks) |
| 501 | } |
| 502 | |
| 503 | func (s *clientQueryServiceServer) ServiceDescriptor() ([]byte, int) { |
| 504 | return twirpFileDescriptor1, 0 |
| 505 | } |
| 506 | |
| 507 | func (s *clientQueryServiceServer) ProtocGenTwirpVersion() string { |
| 508 | return "v8.1.3" |
| 509 | } |
| 510 | |
| 511 | // PathPrefix returns the base service path, in the form: "/<prefix>/<package>.<Service>/" |
| 512 | // that is everything in a Twirp route except for the <Method>. This can be used for routing, |
| 513 | // for example to identify the requests that are targeted to this service in a mux. |
| 514 | func (s *clientQueryServiceServer) PathPrefix() string { |
| 515 | return baseServicePath(s.pathPrefix, "protocol", "ClientQueryService") |
| 516 | } |
| 517 | |
| 518 | var twirpFileDescriptor1 = []byte{ |
| 519 | // 236 bytes of a gzipped FileDescriptorProto |
| 520 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xc1, 0x4a, 0xc3, 0x40, |
| 521 | 0x10, 0x86, 0x89, 0x42, 0xad, 0x53, 0x4f, 0xa3, 0x94, 0x50, 0x2c, 0x94, 0x5c, 0x2c, 0x08, 0x1b, |
| 522 | 0xa9, 0x6f, 0x50, 0x0f, 0x8a, 0x78, 0x31, 0x7a, 0xf2, 0xa2, 0x71, 0x19, 0x62, 0x20, 0xdd, 0xd9, |
| 523 | 0xee, 0x4c, 0x04, 0xdf, 0x5e, 0xba, 0x69, 0x6d, 0x44, 0x3c, 0xed, 0xce, 0xff, 0x2d, 0x3f, 0xdf, |
| 524 | 0x0e, 0x4c, 0xc5, 0x93, 0xcd, 0x7d, 0x60, 0xe5, 0xdc, 0x36, 0x35, 0x39, 0x7d, 0x5d, 0xb7, 0x14, |
| 525 | 0xbe, 0x4c, 0x8c, 0x70, 0x18, 0x0f, 0xcb, 0x4d, 0xb6, 0x84, 0x93, 0x9b, 0xc8, 0x9f, 0x5b, 0xe7, |
| 526 | 0xa8, 0xc1, 0x09, 0x0c, 0x3f, 0x58, 0xd4, 0x95, 0x2b, 0x4a, 0x93, 0x59, 0x32, 0x3f, 0x2e, 0x7e, |
| 527 | 0x66, 0x1c, 0xc3, 0x40, 0xcb, 0x50, 0x91, 0xa6, 0x07, 0x91, 0x6c, 0xa7, 0xec, 0x0c, 0xf0, 0xa1, |
| 528 | 0x96, 0x6d, 0x83, 0x14, 0xb4, 0x6e, 0x49, 0x34, 0xbb, 0x85, 0xd3, 0x5f, 0xa9, 0x78, 0x76, 0x42, |
| 529 | 0x78, 0x05, 0x47, 0xda, 0x45, 0x69, 0x32, 0x3b, 0x9c, 0x8f, 0x16, 0x63, 0xb3, 0x93, 0x31, 0x7d, |
| 530 | 0x93, 0x62, 0xf7, 0x6c, 0xf1, 0x06, 0xd8, 0x81, 0xc7, 0xcd, 0x0f, 0x9e, 0x28, 0x7c, 0xd6, 0x96, |
| 531 | 0xf0, 0x1e, 0x46, 0xbd, 0x7a, 0x3c, 0xdf, 0xb7, 0xfc, 0x75, 0x99, 0x4c, 0xff, 0xa1, 0x9d, 0xd3, |
| 532 | 0xf2, 0xf2, 0x2e, 0x79, 0xb9, 0xa8, 0xd8, 0xac, 0xea, 0x50, 0x56, 0x24, 0xbe, 0xb4, 0x64, 0x2c, |
| 533 | 0xe7, 0x9b, 0x1d, 0x2a, 0x85, 0x7c, 0xbf, 0x4b, 0xcb, 0xcd, 0xfb, 0x20, 0xde, 0xae, 0xbf, 0x03, |
| 534 | 0x00, 0x00, 0xff, 0xff, 0xca, 0x06, 0x49, 0xa5, 0x63, 0x01, 0x00, 0x00, |
| 535 | } |