Documentation
¶
Overview ¶
Package netutil implements some basic functions to send http request and get ip info. Note: HttpGet, HttpPost, HttpDelete, HttpPut, HttpPatch, function param `url` is required. HttpGet, HttpPost, HttpDelete, HttpPut, HttpPatch, function param `params` is variable, the order is: params[0] is header which type should be http.Header or map[string]string, params[1] is query param which type should be url.Values or map[string]any, when content-type header is multipart/form-data or application/x-www-form-urlencoded, params[1] should be url.Values params[2] is post body which type should be []byte. params[3] is http client which type should be http.Client.
Index ¶
- func ConvertMapToQueryString(param map[string]any) string
- func GetInternalIp() string
- func GetIps() []string
- func GetMacAddrs() []string
- func HttpDelete(url string, params ...any) (*http.Response, error)
- func HttpGet(url string, params ...any) (*http.Response, error)
- func HttpPatch(url string, params ...any) (*http.Response, error)
- func HttpPost(url string, params ...any) (*http.Response, error)
- func HttpPut(url string, params ...any) (*http.Response, error)
- func IsPublicIP(IP net.IP) bool
- func ParseHttpResponse(resp *http.Response, obj any) error
- type PublicIpInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertMapToQueryString ¶
ConvertMapToQueryString convert map to sorted url query string
func HttpDelete ¶
HttpDelete send delete http request
Types ¶
type PublicIpInfo ¶
type PublicIpInfo struct { Status string `json:"status"` Country string `json:"country"` CountryCode string `json:"countryCode"` Region string `json:"region"` RegionName string `json:"regionName"` City string `json:"city"` Lat float64 `json:"lat"` Lon float64 `json:"lon"` Isp string `json:"isp"` Org string `json:"org"` As string `json:"as"` Ip string `json:"query"` }
PublicIpInfo public ip info: country, region, isp, city, lat, lon, ip
func GetPublicIpInfo ¶
func GetPublicIpInfo() (*PublicIpInfo, error)
GetPublicIpInfo return public ip information return the PublicIpInfo struct