rest

package
v0.0.0-...-589da53 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package rest contains code for running the REST-to-gRPC gateway.

In order to add a new REST endpoint, add an entry to `gateway/rest/grpc-rest-bindings.yml`.

Run `make proto` to generate (among others) the swagger json file.

Run `make rest_check` to make sure that all the endpoints in the bindings yaml file make it into the swagger json file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGzipHandler

func NewGzipHandler(logger logging.Logger, fn http.HandlerFunc) http.HandlerFunc

Types

type HTTPBodyDelimitedMarshaler

type HTTPBodyDelimitedMarshaler struct {
	runtime.HTTPBodyMarshaler
	// contains filtered or unexported fields
}

This is because by default the marshaller wants to put a newline between chunks of the stream response.

func (*HTTPBodyDelimitedMarshaler) Delimiter

func (o *HTTPBodyDelimitedMarshaler) Delimiter() []byte

type JSONPb

type JSONPb jsonpb.Marshaler

JSONPb is a runtime.Marshaler which marshals/unmarshals into/from.

func (*JSONPb) ContentType

func (*JSONPb) ContentType(interface{}) string

ContentType always returns "application/json".

func (*JSONPb) Delimiter

func (j *JSONPb) Delimiter() []byte

Delimiter for newline encoded JSON streams.

func (*JSONPb) Marshal

func (j *JSONPb) Marshal(v interface{}) ([]byte, error)

Marshal marshals "v" into JSON.

func (*JSONPb) NewDecoder

func (j *JSONPb) NewDecoder(r io.Reader) runtime.Decoder

NewDecoder returns a runtime.Decoder which reads JSON stream from "r".

func (*JSONPb) NewEncoder

func (j *JSONPb) NewEncoder(w io.Writer) runtime.Encoder

NewEncoder returns an Encoder which writes JSON stream into "w".

func (*JSONPb) Unmarshal

func (j *JSONPb) Unmarshal(data []byte, v interface{}) error

Unmarshal unmarshals JSON "data" into "v". Currently it can only marshal proto.Message.

type ProxyServer

type ProxyServer struct {
	gateway.Config
	// contains filtered or unexported fields
}

ProxyServer implement a rest server acting as a proxy to the grpc api.

func NewProxyServer

func NewProxyServer(log *logging.Logger, config gateway.Config, furyPaths paths.Paths) *ProxyServer

NewProxyServer returns a new instance of the rest proxy server.

func (*ProxyServer) ReloadConf

func (s *ProxyServer) ReloadConf(cfg gateway.Config)

ReloadConf update the internal configuration of the server.

func (*ProxyServer) Start

func (s *ProxyServer) Start(ctx context.Context) (http.Handler, error)

Start start the server.

Jump to

Keyboard shortcuts

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