rest

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEngine

func NewEngine(c RestConf) *engine

func UseRoutesMiddleWares

func UseRoutesMiddleWares(m ...gin.HandlerFunc) func(f *featuredRoutes)

Types

type ConsulConf

type ConsulConf struct {
	Host string   `json:"host"`
	Key  string   `json:"key"`
	Tags []string `json:"tags"`
}

type Middlerware

type Middlerware gin.HandlerFunc

type RestConf

type RestConf struct {
	Host         string     `json:"host,default=0.0.0.0"`
	Port         int        `json:"port"`
	MaxConns     int        `json:"maxConns,default=10000"`
	MaxBytes     int64      `json:",default=1048576,range=[0:33554432]"`
	Timeout      int64      `json:"timeout,default=3000"`
	CpuThreshold int64      `json:"cpuThreshold,default=900, range=[0,1000]"`
	CertFile     string     `json:",optional"`
	KeyFile      string     `json:",optional"`
	Verbose      bool       `json:",optional"`
	Mode         string     `json:"mode,optional"`
	Consul       ConsulConf `json:"consul`
}

type Route

type Route struct {
	Method  string
	Path    string
	Handler gin.HandlerFunc
}

type RouteOption

type RouteOption func(r *featuredRoutes)

type RunOption

type RunOption func(*Server)

type Server

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

func MustNewServer

func MustNewServer(c RestConf, opts ...RunOption) *Server

func NewServer

func NewServer(c RestConf, opts ...RunOption) (*Server, error)

func (*Server) AddRoute

func (s *Server) AddRoute(urlPrefix string, r Route, opts ...RouteOption)

func (*Server) AddRoutes

func (s *Server) AddRoutes(UrlPrefix string, rs []Route, opts ...RouteOption)

func (*Server) Start

func (s *Server) Start()

func (*Server) Use

func (s *Server) Use(m ...gin.HandlerFunc)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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