rest

package
v0.70.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 26 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 MetricCollectionMiddleware

func MetricCollectionMiddleware(next http.Handler) http.Handler

MetricCollectionMiddleware records the request and the time taken to service it.

func RemoteAddrMiddleware

func RemoteAddrMiddleware(log *logging.Logger, next http.Handler) http.Handler

RemoteAddrMiddleware is a middleware adding to the current request context the address of the caller.

Types

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 {
	// 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 api.Config) *ProxyServer

NewProxyServer returns a new instance of the rest proxy server.

func (*ProxyServer) ReloadConf

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

ReloadConf update the internal configuration of the server.

func (*ProxyServer) Start

func (s *ProxyServer) Start()

Start starts the server.

func (*ProxyServer) Stop

func (s *ProxyServer) Stop()

Stop stops the server.

Jump to

Keyboard shortcuts

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