grpcgateway

package
v0.0.131 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 33 Imported by: 1

Documentation

Overview

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptyGRPCGatewayOption

type EmptyGRPCGatewayOption struct{}

EmptyGRPCGatewayOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type GRPCGateway

type GRPCGateway struct {
	http.Server
	//assigned by ginRouter in PrepareRun
	Handler http.Handler
	// contains filtered or unexported fields
}

func NewGRPCGateWay

func NewGRPCGateWay(addr string, options ...GRPCGatewayOption) *GRPCGateway

func (*GRPCGateway) ApplyOptions

func (o *GRPCGateway) ApplyOptions(options ...GRPCGatewayOption) *GRPCGateway

func (*GRPCGateway) ListenAndServe

func (g *GRPCGateway) ListenAndServe() error

func (*GRPCGateway) RegisterGRPCHandler

func (g *GRPCGateway) RegisterGRPCHandler(h func(srv *grpc.Server))

func (*GRPCGateway) RegisterHTTPHandler

func (g *GRPCGateway) RegisterHTTPHandler(ctx context.Context,
	h func(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error,
) error

func (*GRPCGateway) ServeHTTP added in v0.0.74

func (g *GRPCGateway) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP, wrap g.gateMux httpServerOpts, and called by grpcHandlerFunc

type GRPCGatewayOption

type GRPCGatewayOption interface {
	// contains filtered or unexported methods
}

A GRPCGatewayOption sets options.

func WithClientDialOptions

func WithClientDialOptions(opts ...grpc.DialOption) GRPCGatewayOption

func WithGatewayMuxOptions added in v0.0.28

func WithGatewayMuxOptions(opts ...runtime.ServeMuxOption) GRPCGatewayOption

func WithHttpHandlerInterceptorCleanPathOptions added in v0.0.99

func WithHttpHandlerInterceptorCleanPathOptions() GRPCGatewayOption

CleanPath

func WithHttpHandlerInterceptorInOutputHeaderPrinterOptions added in v0.0.96

func WithHttpHandlerInterceptorInOutputHeaderPrinterOptions(enabled bool) GRPCGatewayOption

func WithHttpHandlerInterceptorInOutputPrinterOptions added in v0.0.95

func WithHttpHandlerInterceptorInOutputPrinterOptions(enabled bool) GRPCGatewayOption

func WithHttpHandlerInterceptorOptions added in v0.0.68

func WithHttpHandlerInterceptorOptions(handlers ...http_.HandlerInterceptor) GRPCGatewayOption

WithHttpHandlerInterceptorOptions

func WithHttpHandlerInterceptorRecoveryOptions added in v0.0.95

func WithHttpHandlerInterceptorRecoveryOptions() GRPCGatewayOption

recovery

func WithHttpHandlerInterceptorRequestIDOptions added in v0.0.95

func WithHttpHandlerInterceptorRequestIDOptions() GRPCGatewayOption

WithHttpHandlerInterceptorRequestIDOptions

func WithHttpHandlerInterceptorTimeoutOptions added in v0.0.99

func WithHttpHandlerInterceptorTimeoutOptions(timeout time.Duration) GRPCGatewayOption

timeout

func WithHttpHandlerInterceptorsLimitAllOptions added in v0.0.95

func WithHttpHandlerInterceptorsLimitAllOptions(burst int) GRPCGatewayOption

func WithHttpHandlerInterceptorsMetricOptions added in v0.0.101

func WithHttpHandlerInterceptorsMetricOptions() GRPCGatewayOption

func WithHttpHandlerInterceptorsTimerOptions added in v0.0.74

func WithHttpHandlerInterceptorsTimerOptions() GRPCGatewayOption

func WithHttpPostHandlerInterceptorOptions added in v0.0.74

func WithHttpPostHandlerInterceptorOptions(
	handlers ...func(w http.ResponseWriter, r *http.Request),
) GRPCGatewayOption

WithHttpPostHandlerInterceptorOptions

func WithHttpPreHandlerInterceptorOptions added in v0.0.74

func WithHttpPreHandlerInterceptorOptions(
	handlers ...func(w http.ResponseWriter, r *http.Request) error,
) GRPCGatewayOption

WithHttpPreHandlerInterceptorOptions

func WithServerInterceptorTimeoutOptions added in v0.0.97

func WithServerInterceptorTimeoutOptions(timeout time.Duration) GRPCGatewayOption

timeout

func WithServerInterceptorsHTTPForwardResponseOptions added in v0.0.28

func WithServerInterceptorsHTTPForwardResponseOptions() GRPCGatewayOption

now unused, only called by successed response, only append message to response

func WithServerInterceptorsHttpBodyProtoOptions added in v0.0.96

func WithServerInterceptorsHttpBodyProtoOptions() GRPCGatewayOption

http body proto Marshal

func WithServerInterceptorsLimitRateOptions added in v0.0.31

func WithServerInterceptorsLimitRateOptions(burstUnary, burstStream int) GRPCGatewayOption

limiter rate for grpc api

func WithServerInterceptorsLogrusOptions added in v0.0.28

func WithServerInterceptorsLogrusOptions(
	logger *logrus.Logger,
) GRPCGatewayOption

func WithServerInterceptorsRecoveryOptions added in v0.0.38

func WithServerInterceptorsRecoveryOptions() GRPCGatewayOption

recover

func WithServerInterceptorsTCloud30HTTPResponseOptions added in v0.0.28

func WithServerInterceptorsTCloud30HTTPResponseOptions() GRPCGatewayOption

tcloud api3.0 http response formatter

func WithServerInterceptorsTCloud30HttpErrorOptions added in v0.0.90

func WithServerInterceptorsTCloud30HttpErrorOptions() GRPCGatewayOption

HTTP, only called by failed response

func WithServerInterceptorsTrivialV1HTTPForwardResponseOptions added in v0.0.90

func WithServerInterceptorsTrivialV1HTTPForwardResponseOptions() GRPCGatewayOption

now unused, only called by successed response

func WithServerInterceptorsTrivialV1HTTPResponseOptions added in v0.0.90

func WithServerInterceptorsTrivialV1HTTPResponseOptions() GRPCGatewayOption

trivial api1.0 http response formatter

func WithServerInterceptorsTrivialV1HttpErrorOptions added in v0.0.90

func WithServerInterceptorsTrivialV1HttpErrorOptions() GRPCGatewayOption

HTTP, only called by failed response

func WithServerInterceptorsTrivialV2HTTPResponseOptions added in v0.0.104

func WithServerInterceptorsTrivialV2HTTPResponseOptions() GRPCGatewayOption

trivial api2.0 http response formatter

func WithServerInterceptorsTrivialV2HttpErrorOptions added in v0.0.104

func WithServerInterceptorsTrivialV2HttpErrorOptions() GRPCGatewayOption

HTTP, only called by failed response

func WithServerOptions

func WithServerOptions(opts ...grpc.ServerOption) GRPCGatewayOption

func WithServerStreamInterceptorsOptions added in v0.0.27

func WithServerStreamInterceptorsOptions(opts ...grpc.StreamServerInterceptor) GRPCGatewayOption

func WithServerUnaryInterceptorsCodeMessageOptions added in v0.0.36

func WithServerUnaryInterceptorsCodeMessageOptions(enabledMetric bool) GRPCGatewayOption

func WithServerUnaryInterceptorsErrorOptions added in v0.0.28

func WithServerUnaryInterceptorsErrorOptions() GRPCGatewayOption

func WithServerUnaryInterceptorsInOutPacketOptions added in v0.0.57

func WithServerUnaryInterceptorsInOutPacketOptions() GRPCGatewayOption

func WithServerUnaryInterceptorsOptions added in v0.0.27

func WithServerUnaryInterceptorsOptions(opts ...grpc.UnaryServerInterceptor) GRPCGatewayOption

func WithServerUnaryInterceptorsRequestIdOptions added in v0.0.28

func WithServerUnaryInterceptorsRequestIdOptions() GRPCGatewayOption

func WithServerUnaryInterceptorsTimerOptions added in v0.0.28

func WithServerUnaryInterceptorsTimerOptions(enabledMetric bool) GRPCGatewayOption

func WithServerUnaryMetricInterceptorOptions added in v0.0.101

func WithServerUnaryMetricInterceptorOptions() GRPCGatewayOption

type GRPCGatewayOptionFunc

type GRPCGatewayOptionFunc func(*GRPCGateway)

GRPCGatewayOptionFunc wraps a function that modifies Client into an implementation of the GRPCGatewayOption interface.

type GRPCHandler

type GRPCHandler interface {
	Register(srv *grpc.Server)
}

type GRPCHandlerFunc

type GRPCHandlerFunc func(srv *grpc.Server)

func (GRPCHandlerFunc) Register

func (h GRPCHandlerFunc) Register(srv *grpc.Server)

type HTTPHandler

type HTTPHandler interface {
	Register(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error
}

type HTTPHandlerFunc

type HTTPHandlerFunc func(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error

func (HTTPHandlerFunc) Register

func (h HTTPHandlerFunc) Register(
	ctx context.Context,
	mux *runtime.ServeMux,
	endpoint string,
	opts []grpc.DialOption,
) error

type InterceptorOption added in v0.0.27

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

Directories

Path Synopsis
Package date is a reverse proxy.
Package date is a reverse proxy.

Jump to

Keyboard shortcuts

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