rest

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTConfig

type JWTConfig struct {
	Secret string `yaml:"secret"` // jwt密钥
	Exp    int64  `yaml:"exp"`    // 过期时间(秒)
	Issuer string `yaml:"issuer"` // 签发者
}

type RestConf

type RestConf struct {
	ServiceConf `yaml:",inline"`
	Host        string `yaml:"host"`
	Port        int    `yaml:"port"`
	RouteRoot   string `yaml:"route-root"`
	CorsEnable  bool   `yaml:"cors-enable"`
	Verbose     bool   `yaml:"verbose"` //日志内容(默认简单,设置true为详细日志)
}

type RunOption

type RunOption func(*Server)

func WithCors

func WithCors() RunOption

type Server

type Server struct {
	Conf   RestConf
	Engine *gin.Engine
}

func MustNewServer

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

func NewServer

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

func (*Server) Start

func (s *Server) Start()

type ServiceConf

type ServiceConf struct {
	Name       string            `yaml:"name"`
	Mode       string            `yaml:"mode"`
	MetricsUrl string            `yaml:"metrics-url"`
	JWT        JWTConfig         `yaml:"jwt"`
	SqlConf    sqlx.Config       `yaml:"sql"`
	RedisConf  redis.Config      `yaml:"redis"`
	Prometheus prometheus.Config `yaml:"prometheus"`
	Trace      trace.Config      `yaml:"trace"`
}

Directories

Path Synopsis
common

Jump to

Keyboard shortcuts

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