// Code generated by protoc-gen-twirp v8.1.3, DO NOT EDIT. // source: spec/proto/pki.proto package protocol import context "context" import fmt "fmt" import http "net/http" import io "io" import json "encoding/json" import strconv "strconv" import strings "strings" import protojson "google.golang.org/protobuf/encoding/protojson" import twirp "github.com/twitchtv/twirp" import ctxsetters "github.com/twitchtv/twirp/ctxsetters" // Version compatibility assertion. // If the constant is not defined in the package, that likely means // the package needs to be updated to work with this generated code. // See https://twitchtv.github.io/twirp/docs/version_matrix.html const _ = twirp.TwirpPackageMinVersion_8_1_0 // ==================== // PKIService Interface // ==================== type PKIService interface { RequestCertificate(context.Context, *CertificateRequest) (*CertificateResponse, error) RenewCertificate(context.Context, *CertificateRenewalRequest) (*CertificateResponse, error) } // ========================== // PKIService Protobuf Client // ========================== type pKIServiceProtobufClient struct { client HTTPClient urls [2]string interceptor twirp.Interceptor opts twirp.ClientOptions } // NewPKIServiceProtobufClient creates a Protobuf client that implements the PKIService interface. // It communicates using Protobuf and can be configured with a custom HTTPClient. func NewPKIServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) PKIService { if c, ok := client.(*http.Client); ok { client = withoutRedirects(c) } clientOpts := twirp.ClientOptions{} for _, o := range opts { o(&clientOpts) } // Using ReadOpt allows backwards and forwards compatibility with new options in the future literalURLs := false _ = clientOpts.ReadOpt("literalURLs", &literalURLs) var pathPrefix string if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { pathPrefix = "/twirp" // default prefix } // Build method URLs: []/./ serviceURL := sanitizeBaseURL(baseURL) serviceURL += baseServicePath(pathPrefix, "protocol", "PKIService") urls := [2]string{ serviceURL + "RequestCertificate", serviceURL + "RenewCertificate", } return &pKIServiceProtobufClient{ client: client, urls: urls, interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), opts: clientOpts, } } func (c *pKIServiceProtobufClient) RequestCertificate(ctx context.Context, in *CertificateRequest) (*CertificateResponse, error) { ctx = ctxsetters.WithPackageName(ctx, "protocol") ctx = ctxsetters.WithServiceName(ctx, "PKIService") ctx = ctxsetters.WithMethodName(ctx, "RequestCertificate") caller := c.callRequestCertificate if c.interceptor != nil { caller = func(ctx context.Context, req *CertificateRequest) (*CertificateResponse, error) { resp, err := c.interceptor( func(ctx context.Context, req interface{}) (interface{}, error) { typedReq, ok := req.(*CertificateRequest) if !ok { return nil, twirp.InternalError("failed type assertion req.(*CertificateRequest) when calling interceptor") } return c.callRequestCertificate(ctx, typedReq) }, )(ctx, req) if resp != nil { typedResp, ok := resp.(*CertificateResponse) if !ok { return nil, twirp.InternalError("failed type assertion resp.(*CertificateResponse) when calling interceptor") } return typedResp, err } return nil, err } } return caller(ctx, in) } func (c *pKIServiceProtobufClient) callRequestCertificate(ctx context.Context, in *CertificateRequest) (*CertificateResponse, error) { out := new(CertificateResponse) ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) if err != nil { twerr, ok := err.(twirp.Error) if !ok { twerr = twirp.InternalErrorWith(err) } callClientError(ctx, c.opts.Hooks, twerr) return nil, err } callClientResponseReceived(ctx, c.opts.Hooks) return out, nil } func (c *pKIServiceProtobufClient) RenewCertificate(ctx context.Context, in *CertificateRenewalRequest) (*CertificateResponse, error) { ctx = ctxsetters.WithPackageName(ctx, "protocol") ctx = ctxsetters.WithServiceName(ctx, "PKIService") ctx = ctxsetters.WithMethodName(ctx, "RenewCertificate") caller := c.callRenewCertificate if c.interceptor != nil { caller = func(ctx context.Context, req *CertificateRenewalRequest) (*CertificateResponse, error) { resp, err := c.interceptor( func(ctx context.Context, req interface{}) (interface{}, error) { typedReq, ok := req.(*CertificateRenewalRequest) if !ok { return nil, twirp.InternalError("failed type assertion req.(*CertificateRenewalRequest) when calling interceptor") } return c.callRenewCertificate(ctx, typedReq) }, )(ctx, req) if resp != nil { typedResp, ok := resp.(*CertificateResponse) if !ok { return nil, twirp.InternalError("failed type assertion resp.(*CertificateResponse) when calling interceptor") } return typedResp, err } return nil, err } } return caller(ctx, in) } func (c *pKIServiceProtobufClient) callRenewCertificate(ctx context.Context, in *CertificateRenewalRequest) (*CertificateResponse, error) { out := new(CertificateResponse) ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) if err != nil { twerr, ok := err.(twirp.Error) if !ok { twerr = twirp.InternalErrorWith(err) } callClientError(ctx, c.opts.Hooks, twerr) return nil, err } callClientResponseReceived(ctx, c.opts.Hooks) return out, nil } // ====================== // PKIService JSON Client // ====================== type pKIServiceJSONClient struct { client HTTPClient urls [2]string interceptor twirp.Interceptor opts twirp.ClientOptions } // NewPKIServiceJSONClient creates a JSON client that implements the PKIService interface. // It communicates using JSON and can be configured with a custom HTTPClient. func NewPKIServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) PKIService { if c, ok := client.(*http.Client); ok { client = withoutRedirects(c) } clientOpts := twirp.ClientOptions{} for _, o := range opts { o(&clientOpts) } // Using ReadOpt allows backwards and forwards compatibility with new options in the future literalURLs := false _ = clientOpts.ReadOpt("literalURLs", &literalURLs) var pathPrefix string if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { pathPrefix = "/twirp" // default prefix } // Build method URLs: []/./ serviceURL := sanitizeBaseURL(baseURL) serviceURL += baseServicePath(pathPrefix, "protocol", "PKIService") urls := [2]string{ serviceURL + "RequestCertificate", serviceURL + "RenewCertificate", } return &pKIServiceJSONClient{ client: client, urls: urls, interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), opts: clientOpts, } } func (c *pKIServiceJSONClient) RequestCertificate(ctx context.Context, in *CertificateRequest) (*CertificateResponse, error) { ctx = ctxsetters.WithPackageName(ctx, "protocol") ctx = ctxsetters.WithServiceName(ctx, "PKIService") ctx = ctxsetters.WithMethodName(ctx, "RequestCertificate") caller := c.callRequestCertificate if c.interceptor != nil { caller = func(ctx context.Context, req *CertificateRequest) (*CertificateResponse, error) { resp, err := c.interceptor( func(ctx context.Context, req interface{}) (interface{}, error) { typedReq, ok := req.(*CertificateRequest) if !ok { return nil, twirp.InternalError("failed type assertion req.(*CertificateRequest) when calling interceptor") } return c.callRequestCertificate(ctx, typedReq) }, )(ctx, req) if resp != nil { typedResp, ok := resp.(*CertificateResponse) if !ok { return nil, twirp.InternalError("failed type assertion resp.(*CertificateResponse) when calling interceptor") } return typedResp, err } return nil, err } } return caller(ctx, in) } func (c *pKIServiceJSONClient) callRequestCertificate(ctx context.Context, in *CertificateRequest) (*CertificateResponse, error) { out := new(CertificateResponse) ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) if err != nil { twerr, ok := err.(twirp.Error) if !ok { twerr = twirp.InternalErrorWith(err) } callClientError(ctx, c.opts.Hooks, twerr) return nil, err } callClientResponseReceived(ctx, c.opts.Hooks) return out, nil } func (c *pKIServiceJSONClient) RenewCertificate(ctx context.Context, in *CertificateRenewalRequest) (*CertificateResponse, error) { ctx = ctxsetters.WithPackageName(ctx, "protocol") ctx = ctxsetters.WithServiceName(ctx, "PKIService") ctx = ctxsetters.WithMethodName(ctx, "RenewCertificate") caller := c.callRenewCertificate if c.interceptor != nil { caller = func(ctx context.Context, req *CertificateRenewalRequest) (*CertificateResponse, error) { resp, err := c.interceptor( func(ctx context.Context, req interface{}) (interface{}, error) { typedReq, ok := req.(*CertificateRenewalRequest) if !ok { return nil, twirp.InternalError("failed type assertion req.(*CertificateRenewalRequest) when calling interceptor") } return c.callRenewCertificate(ctx, typedReq) }, )(ctx, req) if resp != nil { typedResp, ok := resp.(*CertificateResponse) if !ok { return nil, twirp.InternalError("failed type assertion resp.(*CertificateResponse) when calling interceptor") } return typedResp, err } return nil, err } } return caller(ctx, in) } func (c *pKIServiceJSONClient) callRenewCertificate(ctx context.Context, in *CertificateRenewalRequest) (*CertificateResponse, error) { out := new(CertificateResponse) ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) if err != nil { twerr, ok := err.(twirp.Error) if !ok { twerr = twirp.InternalErrorWith(err) } callClientError(ctx, c.opts.Hooks, twerr) return nil, err } callClientResponseReceived(ctx, c.opts.Hooks) return out, nil } // ========================= // PKIService Server Handler // ========================= type pKIServiceServer struct { PKIService interceptor twirp.Interceptor hooks *twirp.ServerHooks pathPrefix string // prefix for routing jsonSkipDefaults bool // do not include unpopulated fields (default values) in the response jsonCamelCase bool // JSON fields are serialized as lowerCamelCase rather than keeping the original proto names } // NewPKIServiceServer builds a TwirpServer that can be used as an http.Handler to handle // HTTP requests that are routed to the right method in the provided svc implementation. // The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks). func NewPKIServiceServer(svc PKIService, opts ...interface{}) TwirpServer { serverOpts := newServerOpts(opts) // Using ReadOpt allows backwards and forwards compatibility with new options in the future jsonSkipDefaults := false _ = serverOpts.ReadOpt("jsonSkipDefaults", &jsonSkipDefaults) jsonCamelCase := false _ = serverOpts.ReadOpt("jsonCamelCase", &jsonCamelCase) var pathPrefix string if ok := serverOpts.ReadOpt("pathPrefix", &pathPrefix); !ok { pathPrefix = "/twirp" // default prefix } return &pKIServiceServer{ PKIService: svc, hooks: serverOpts.Hooks, interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...), pathPrefix: pathPrefix, jsonSkipDefaults: jsonSkipDefaults, jsonCamelCase: jsonCamelCase, } } // writeError writes an HTTP response with a valid Twirp error format, and triggers hooks. // If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) func (s *pKIServiceServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) { writeError(ctx, resp, err, s.hooks) } // handleRequestBodyError is used to handle error when the twirp server cannot read request func (s *pKIServiceServer) handleRequestBodyError(ctx context.Context, resp http.ResponseWriter, msg string, err error) { if context.Canceled == ctx.Err() { s.writeError(ctx, resp, twirp.NewError(twirp.Canceled, "failed to read request: context canceled")) return } if context.DeadlineExceeded == ctx.Err() { s.writeError(ctx, resp, twirp.NewError(twirp.DeadlineExceeded, "failed to read request: deadline exceeded")) return } s.writeError(ctx, resp, twirp.WrapError(malformedRequestError(msg), err)) } // PKIServicePathPrefix is a convenience constant that may identify URL paths. // Should be used with caution, it only matches routes generated by Twirp Go clients, // with the default "/twirp" prefix and default CamelCase service and method names. // More info: https://twitchtv.github.io/twirp/docs/routing.html const PKIServicePathPrefix = "/twirp/protocol.PKIService/" func (s *pKIServiceServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { ctx := req.Context() ctx = ctxsetters.WithPackageName(ctx, "protocol") ctx = ctxsetters.WithServiceName(ctx, "PKIService") ctx = ctxsetters.WithResponseWriter(ctx, resp) var err error ctx, err = callRequestReceived(ctx, s.hooks) if err != nil { s.writeError(ctx, resp, err) return } if req.Method != "POST" { msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method) s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) return } // Verify path format: []/./ prefix, pkgService, method := parseTwirpPath(req.URL.Path) if pkgService != "protocol.PKIService" { msg := fmt.Sprintf("no handler for path %q", req.URL.Path) s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) return } if prefix != s.pathPrefix { msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path) s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) return } switch method { case "RequestCertificate": s.serveRequestCertificate(ctx, resp, req) return case "RenewCertificate": s.serveRenewCertificate(ctx, resp, req) return default: msg := fmt.Sprintf("no handler for path %q", req.URL.Path) s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) return } } func (s *pKIServiceServer) serveRequestCertificate(ctx context.Context, resp http.ResponseWriter, req *http.Request) { header := req.Header.Get("Content-Type") i := strings.Index(header, ";") if i == -1 { i = len(header) } switch strings.TrimSpace(strings.ToLower(header[:i])) { case "application/json": s.serveRequestCertificateJSON(ctx, resp, req) case "application/protobuf": s.serveRequestCertificateProtobuf(ctx, resp, req) default: msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) twerr := badRouteError(msg, req.Method, req.URL.Path) s.writeError(ctx, resp, twerr) } } func (s *pKIServiceServer) serveRequestCertificateJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { var err error ctx = ctxsetters.WithMethodName(ctx, "RequestCertificate") ctx, err = callRequestRouted(ctx, s.hooks) if err != nil { s.writeError(ctx, resp, err) return } d := json.NewDecoder(req.Body) rawReqBody := json.RawMessage{} if err := d.Decode(&rawReqBody); err != nil { s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) return } reqContent := new(CertificateRequest) unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) return } handler := s.PKIService.RequestCertificate if s.interceptor != nil { handler = func(ctx context.Context, req *CertificateRequest) (*CertificateResponse, error) { resp, err := s.interceptor( func(ctx context.Context, req interface{}) (interface{}, error) { typedReq, ok := req.(*CertificateRequest) if !ok { return nil, twirp.InternalError("failed type assertion req.(*CertificateRequest) when calling interceptor") } return s.PKIService.RequestCertificate(ctx, typedReq) }, )(ctx, req) if resp != nil { typedResp, ok := resp.(*CertificateResponse) if !ok { return nil, twirp.InternalError("failed type assertion resp.(*CertificateResponse) when calling interceptor") } return typedResp, err } return nil, err } } // Call service method var respContent *CertificateResponse func() { defer ensurePanicResponses(ctx, resp, s.hooks) respContent, err = handler(ctx, reqContent) }() if err != nil { s.writeError(ctx, resp, err) return } if respContent == nil { s.writeError(ctx, resp, twirp.InternalError("received a nil *CertificateResponse and nil error while calling RequestCertificate. nil responses are not supported")) return } ctx = callResponsePrepared(ctx, s.hooks) marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} respBytes, err := marshaler.Marshal(respContent) if err != nil { s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) return } ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) resp.Header().Set("Content-Type", "application/json") resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) resp.WriteHeader(http.StatusOK) if n, err := resp.Write(respBytes); err != nil { msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) twerr := twirp.NewError(twirp.Unknown, msg) ctx = callError(ctx, s.hooks, twerr) } callResponseSent(ctx, s.hooks) } func (s *pKIServiceServer) serveRequestCertificateProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { var err error ctx = ctxsetters.WithMethodName(ctx, "RequestCertificate") ctx, err = callRequestRouted(ctx, s.hooks) if err != nil { s.writeError(ctx, resp, err) return } buf, err := io.ReadAll(req.Body) if err != nil { s.handleRequestBodyError(ctx, resp, "failed to read request body", err) return } reqContent := new(CertificateRequest) if err = reqContent.UnmarshalVT(buf); err != nil { s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) return } handler := s.PKIService.RequestCertificate if s.interceptor != nil { handler = func(ctx context.Context, req *CertificateRequest) (*CertificateResponse, error) { resp, err := s.interceptor( func(ctx context.Context, req interface{}) (interface{}, error) { typedReq, ok := req.(*CertificateRequest) if !ok { return nil, twirp.InternalError("failed type assertion req.(*CertificateRequest) when calling interceptor") } return s.PKIService.RequestCertificate(ctx, typedReq) }, )(ctx, req) if resp != nil { typedResp, ok := resp.(*CertificateResponse) if !ok { return nil, twirp.InternalError("failed type assertion resp.(*CertificateResponse) when calling interceptor") } return typedResp, err } return nil, err } } // Call service method var respContent *CertificateResponse func() { defer ensurePanicResponses(ctx, resp, s.hooks) respContent, err = handler(ctx, reqContent) }() if err != nil { s.writeError(ctx, resp, err) return } if respContent == nil { s.writeError(ctx, resp, twirp.InternalError("received a nil *CertificateResponse and nil error while calling RequestCertificate. nil responses are not supported")) return } ctx = callResponsePrepared(ctx, s.hooks) respBytes, err := respContent.MarshalVT() if err != nil { s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) return } ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) resp.Header().Set("Content-Type", "application/protobuf") resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) resp.WriteHeader(http.StatusOK) if n, err := resp.Write(respBytes); err != nil { msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) twerr := twirp.NewError(twirp.Unknown, msg) ctx = callError(ctx, s.hooks, twerr) } callResponseSent(ctx, s.hooks) } func (s *pKIServiceServer) serveRenewCertificate(ctx context.Context, resp http.ResponseWriter, req *http.Request) { header := req.Header.Get("Content-Type") i := strings.Index(header, ";") if i == -1 { i = len(header) } switch strings.TrimSpace(strings.ToLower(header[:i])) { case "application/json": s.serveRenewCertificateJSON(ctx, resp, req) case "application/protobuf": s.serveRenewCertificateProtobuf(ctx, resp, req) default: msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) twerr := badRouteError(msg, req.Method, req.URL.Path) s.writeError(ctx, resp, twerr) } } func (s *pKIServiceServer) serveRenewCertificateJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { var err error ctx = ctxsetters.WithMethodName(ctx, "RenewCertificate") ctx, err = callRequestRouted(ctx, s.hooks) if err != nil { s.writeError(ctx, resp, err) return } d := json.NewDecoder(req.Body) rawReqBody := json.RawMessage{} if err := d.Decode(&rawReqBody); err != nil { s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) return } reqContent := new(CertificateRenewalRequest) unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) return } handler := s.PKIService.RenewCertificate if s.interceptor != nil { handler = func(ctx context.Context, req *CertificateRenewalRequest) (*CertificateResponse, error) { resp, err := s.interceptor( func(ctx context.Context, req interface{}) (interface{}, error) { typedReq, ok := req.(*CertificateRenewalRequest) if !ok { return nil, twirp.InternalError("failed type assertion req.(*CertificateRenewalRequest) when calling interceptor") } return s.PKIService.RenewCertificate(ctx, typedReq) }, )(ctx, req) if resp != nil { typedResp, ok := resp.(*CertificateResponse) if !ok { return nil, twirp.InternalError("failed type assertion resp.(*CertificateResponse) when calling interceptor") } return typedResp, err } return nil, err } } // Call service method var respContent *CertificateResponse func() { defer ensurePanicResponses(ctx, resp, s.hooks) respContent, err = handler(ctx, reqContent) }() if err != nil { s.writeError(ctx, resp, err) return } if respContent == nil { s.writeError(ctx, resp, twirp.InternalError("received a nil *CertificateResponse and nil error while calling RenewCertificate. nil responses are not supported")) return } ctx = callResponsePrepared(ctx, s.hooks) marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} respBytes, err := marshaler.Marshal(respContent) if err != nil { s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) return } ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) resp.Header().Set("Content-Type", "application/json") resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) resp.WriteHeader(http.StatusOK) if n, err := resp.Write(respBytes); err != nil { msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) twerr := twirp.NewError(twirp.Unknown, msg) ctx = callError(ctx, s.hooks, twerr) } callResponseSent(ctx, s.hooks) } func (s *pKIServiceServer) serveRenewCertificateProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { var err error ctx = ctxsetters.WithMethodName(ctx, "RenewCertificate") ctx, err = callRequestRouted(ctx, s.hooks) if err != nil { s.writeError(ctx, resp, err) return } buf, err := io.ReadAll(req.Body) if err != nil { s.handleRequestBodyError(ctx, resp, "failed to read request body", err) return } reqContent := new(CertificateRenewalRequest) if err = reqContent.UnmarshalVT(buf); err != nil { s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) return } handler := s.PKIService.RenewCertificate if s.interceptor != nil { handler = func(ctx context.Context, req *CertificateRenewalRequest) (*CertificateResponse, error) { resp, err := s.interceptor( func(ctx context.Context, req interface{}) (interface{}, error) { typedReq, ok := req.(*CertificateRenewalRequest) if !ok { return nil, twirp.InternalError("failed type assertion req.(*CertificateRenewalRequest) when calling interceptor") } return s.PKIService.RenewCertificate(ctx, typedReq) }, )(ctx, req) if resp != nil { typedResp, ok := resp.(*CertificateResponse) if !ok { return nil, twirp.InternalError("failed type assertion resp.(*CertificateResponse) when calling interceptor") } return typedResp, err } return nil, err } } // Call service method var respContent *CertificateResponse func() { defer ensurePanicResponses(ctx, resp, s.hooks) respContent, err = handler(ctx, reqContent) }() if err != nil { s.writeError(ctx, resp, err) return } if respContent == nil { s.writeError(ctx, resp, twirp.InternalError("received a nil *CertificateResponse and nil error while calling RenewCertificate. nil responses are not supported")) return } ctx = callResponsePrepared(ctx, s.hooks) respBytes, err := respContent.MarshalVT() if err != nil { s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) return } ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) resp.Header().Set("Content-Type", "application/protobuf") resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) resp.WriteHeader(http.StatusOK) if n, err := resp.Write(respBytes); err != nil { msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) twerr := twirp.NewError(twirp.Unknown, msg) ctx = callError(ctx, s.hooks, twerr) } callResponseSent(ctx, s.hooks) } func (s *pKIServiceServer) ServiceDescriptor() ([]byte, int) { return twirpFileDescriptor4, 0 } func (s *pKIServiceServer) ProtocGenTwirpVersion() string { return "v8.1.3" } // PathPrefix returns the base service path, in the form: "//./" // that is everything in a Twirp route except for the . This can be used for routing, // for example to identify the requests that are targeted to this service in a mux. func (s *pKIServiceServer) PathPrefix() string { return baseServicePath(s.pathPrefix, "protocol", "PKIService") } var twirpFileDescriptor4 = []byte{ // 284 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xcf, 0x4a, 0xc3, 0x40, 0x10, 0xc6, 0x59, 0x41, 0x2d, 0xa3, 0x48, 0x59, 0x15, 0xda, 0xa2, 0x50, 0xe2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