server

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 15 Imported by: 0

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

Jump to

Keyboard shortcuts

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