httpx

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package httpx gateway.go contains two main API module: HTTP and gRPC. The reason for designing a gateway to serve request both HTTP and gRPC is that DO NOT want to listen on another TCP port so that client could build connections to only one server address.

This design referred: https://eddycjy.com/posts/go/grpc-gateway/2019-06-22-grpc-gateway-tls/

I hope them can help you too.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger() gin.HandlerFunc

func NewGateway

func NewGateway(addr string, s1 http.Handler, s2 *grpc.Server) *gateway

func Recovery

func Recovery() gin.HandlerFunc

func ResponseError

func ResponseError(c *gin.Context, err error)

func ResponseErrorAndAbort

func ResponseErrorAndAbort(c *gin.Context, err error)

func ResponseErrorStatusAndAbort

func ResponseErrorStatusAndAbort(c *gin.Context, status int, err error)

func ResponseJSON

func ResponseJSON(c *gin.Context, data interface{})

Types

type CommonResponse

type CommonResponse struct {
	ErrCode    ErrorCode   `json:"errcode"`
	ErrMessage string      `json:"errmsg,omitempty"`
	Data       interface{} `json:"data,omitempty"`
}

type ErrorCode

type ErrorCode int
const (
	FAILED       ErrorCode = -1
	InvalidParam ErrorCode = -2
	OK           ErrorCode = 0
)

Jump to

Keyboard shortcuts

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