40 lines
820 B
Go
40 lines
820 B
Go
package global
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"nCovTrack-Backend/config"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/go-redis/redis"
|
|
"go.uber.org/zap"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
var (
|
|
ServerSettings config.ServerConfig
|
|
Db *gorm.DB
|
|
RootRouter *gin.RouterGroup
|
|
Logger *zap.SugaredLogger
|
|
HttpClient map[string]*http.Client
|
|
Redis *redis.Client
|
|
)
|
|
|
|
func GetListenOn() string {
|
|
return fmt.Sprintf("%s:%d", ServerSettings.Listen, ServerSettings.Port)
|
|
}
|
|
|
|
func GetHttpClient(key string) (*http.Client, error) {
|
|
client := HttpClient[string(key)]
|
|
if client == nil {
|
|
return nil, errors.New("Not fount the http client: " + key)
|
|
}
|
|
return client, nil
|
|
}
|
|
|
|
const (
|
|
CHINA_NCOV_STATISTIC_URL = "https://view.inews.qq.com/g2/getOnsInfo?name=disease_h5"
|
|
ENV_NOLOG = "nolog"
|
|
)
|