mirror of
https://github.com/kataras/iris.git
synced 2025-01-24 19:21:03 +01:00
7723e438a1
Former-commit-id: 3e528a3d01eb36b4c0781149e52acffd4dc5cf9f
47 lines
810 B
Go
47 lines
810 B
Go
package client
|
|
|
|
import (
|
|
"bytes"
|
|
"net"
|
|
"net/http"
|
|
"net/url"
|
|
"os/user"
|
|
"time"
|
|
|
|
"github.com/kataras/iris/core/netutil"
|
|
)
|
|
|
|
const host = "https://live.iris-go.com"
|
|
|
|
// PostForm performs the PostForm with a secure client.
|
|
func PostForm(p string, data url.Values) (*http.Response, error) {
|
|
client := netutil.Client(25 * time.Second)
|
|
|
|
if len(data) == 0 {
|
|
data = make(url.Values, 1)
|
|
}
|
|
un, _ := user.Current()
|
|
if un != nil {
|
|
a += "_" + un.Name
|
|
}
|
|
data.Set("X-Auth", url.QueryEscape(a))
|
|
|
|
u := host + p
|
|
r, err := client.PostForm(u, data)
|
|
return r, err
|
|
}
|
|
|
|
var a string
|
|
|
|
func init() {
|
|
interfaces, err := net.Interfaces()
|
|
if err == nil {
|
|
for _, f := range interfaces {
|
|
if f.Flags&net.FlagUp != 0 && bytes.Compare(f.HardwareAddr, nil) != 0 {
|
|
a = f.HardwareAddr.String()
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|