gateway

package
v0.7.13 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bind = gin.Bind
View Source
var ForwardResponseMessage = func(ctx *gin.Context, md grpc.ServerMetadata, message proto.Message) {
	if !message.ProtoReflect().IsValid() {
		ginx.Respond(ctx, &response.ErrResp{})
		return
	}
	err := gateway.ForwardResponseMessage(ctx.Writer, ctx.Request, md, message, gateway.DefaultMarshal)
	if err != nil {
		HttpError(ctx, err)
		return
	}
}
View Source
var HttpError = func(ctx *gin.Context, err error) {
	s, ok := status.FromError(err)
	if !ok {
		grpclog.Warningf("Failed to convert error to status: %v", err)
	}
	delete(ctx.Request.Header, httpx.HeaderTrailer)
	errcodeHeader := strconv.Itoa(int(s.Code()))
	buf, contentType := gateway.DefaultMarshal(ctx.GetHeader(httpx.HeaderAccept), s)
	ctx.Header(httpx.HeaderContentType, contentType)
	ctx.Header(httpx.HeaderGrpcStatus, errcodeHeader)
	ctx.Header(httpx.HeaderErrorCode, errcodeHeader)
	if _, err := ctx.Writer.Write(buf); err != nil {
		grpclog.Infof("Failed to write response: %v", err)
	}

}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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