diff --git a/http.go b/http.go index 38f1308..c84a490 100644 --- a/http.go +++ b/http.go @@ -98,6 +98,9 @@ func (app *App) SetContentTypeForm() { // SetParam 设置请求参数 func (app *App) SetParam(key string, value interface{}) { + if key == "" { + panic("url is empty") + } app.httpParams.Set(key, value) } @@ -130,6 +133,14 @@ func (app *App) Request() (httpResponse Response, err error) { // 请求 func request(app *App) (httpResponse Response, err error) { + // 判断网址 + if app.httpUrl == "" { + app.httpUrl = app.Url + } + if app.httpUrl == "" { + return httpResponse, errors.New("没有设置Url") + } + // 创建 http 客户端 client := &http.Client{} diff --git a/ip.go b/ip.go index 34dcda3..894410d 100644 --- a/ip.go +++ b/ip.go @@ -6,7 +6,7 @@ import ( "strings" ) -const Version = "1.0.2" +const Version = "1.0.3" // ClientIp 尽最大努力实现获取客户端 IP 的算法。 // 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。