Documentation

Index

Constants

This section is empty.

Variables

View Source
var RESPONSE = make(map[int]interface{}, 12)

RESPONSE dict

Functions

func RemoteAddr

func RemoteAddr(c *gin.Context) string

RemoteAddr get remote ip address

Types

type BaseServer

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

BaseServer for gRPC

func (*BaseServer) NewEngine

func (s *BaseServer) NewEngine(opts ...Option) *gin.Engine

func (*BaseServer) Start

func (s *BaseServer) Start()

Start http server

type Option

type Option func(options *Options)

type Options

type Options struct {
	Name               string
	Host               string
	Port               int
	SSLCrtFile         string
	SSLKeyFile         string
	DisableCORS        bool
	ReadTimeout        time.Duration
	ReadHeaderTimeout  time.Duration
	WriteTimeout       time.Duration
	MaxHeaderBytes     int
	CORSAllowedMethods []string
	CORSAllowedOrigins []string
	CORSAllowedHeaders []string
}

Options for http server

type Response

type Response struct {
	Data    interface{} `json:"data"`
	Code    int         `json:"code"`
	ErrorNo int         `json:"err_no"`
	Msg     string      `json:"msg"`
}

Response TL;DR

func FormatResponse

func FormatResponse(status int, data interface{}) (int, *Response)

FormatResponse transfer status code to response message return status code, map of response data