mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-10-09 03:26:42 +08:00
28 lines
513 B
Go
28 lines
513 B
Go
package crons
|
|
|
|
import (
|
|
"context"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/text/gstr"
|
|
"hotgo/internal/consts"
|
|
)
|
|
|
|
func webRequest(ctx context.Context, url string) {
|
|
args, _ := ctx.Value(consts.ContextKeyCronArgs).([]string)
|
|
|
|
var (
|
|
method = "GET"
|
|
)
|
|
|
|
for _, v := range args {
|
|
if gstr.Contains(v, "method") {
|
|
method_ := gstr.Split("method", "=")
|
|
if len(method_) == 2 {
|
|
method = gstr.ToUpper(method_[1])
|
|
}
|
|
}
|
|
}
|
|
client := g.Client()
|
|
client.DoRequest(ctx, method, url, nil)
|
|
}
|