transcode

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package transcode serves the REST surface of gRPC services: it maps the google.api.http bindings generated into internal/apidef onto the services' gRPC implementations (AIP-127), validating each request's field behaviours on the way in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transcoder

type Transcoder struct {
	// contains filtered or unexported fields
}

Transcoder serves REST for gRPC services (AIP-127), so REST and gRPC share one code path.

func New

func New() *Transcoder

New returns an empty Transcoder; add services with AddService.

func (*Transcoder) AddServer

func (t *Transcoder) AddServer(name string, impl any) error

AddServer routes the generated HTTP bindings of the named gRPC service to impl's methods, for services whose generated code offers no grpc.ServiceDesc (google.cloud.location.Locations).

func (*Transcoder) AddService

func (t *Transcoder) AddService(sd *grpc.ServiceDesc, impl any) error

AddService routes every method of sd that has a generated HTTP binding (internal/apidef) to impl, through the generated gRPC handlers.

func (*Transcoder) RegisterService

func (t *Transcoder) RegisterService(sd *grpc.ServiceDesc, impl any)

RegisterService implements grpc.ServiceRegistrar, so generated RegisterXServer functions can register onto the REST surface too. It panics if sd has no generated definition: that is a build-time mistake.

func (*Transcoder) ServeHTTP

func (t *Transcoder) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes r to the best matching binding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL