mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
use touka uni httpc
This commit is contained in:
parent
781e175721
commit
904a800eea
11 changed files with 51 additions and 128 deletions
7
main.go
7
main.go
|
|
@ -15,6 +15,7 @@ import (
|
|||
"ghproxy/config"
|
||||
"ghproxy/proxy"
|
||||
|
||||
"github.com/WJQSERVER-STUDIO/httpc"
|
||||
"github.com/fenthope/bauth"
|
||||
|
||||
"ghproxy/weakcache"
|
||||
|
|
@ -33,7 +34,7 @@ var (
|
|||
cfg *config.Config
|
||||
r *touka.Engine
|
||||
configfile = "/data/ghproxy/config/config.toml"
|
||||
hertZfile *os.File
|
||||
httpClient *httpc.Client
|
||||
cfgfile string
|
||||
version string
|
||||
runMode string
|
||||
|
|
@ -165,7 +166,8 @@ func setupApi(cfg *config.Config, r *touka.Engine, version string) {
|
|||
}
|
||||
|
||||
func InitReq(cfg *config.Config) {
|
||||
err := proxy.InitReq(cfg)
|
||||
var err error
|
||||
httpClient, err = proxy.InitReq(cfg)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to initialize request: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
|
@ -335,6 +337,7 @@ func main() {
|
|||
|
||||
r.Use(touka.Recovery()) // Recovery中间件
|
||||
r.SetLogger(logger)
|
||||
r.SetHTTPClient(httpClient)
|
||||
r.Use(record.Middleware()) // log中间件
|
||||
r.Use(viaHeader())
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue