http

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP

func ClientIP(req *http.Request) string

ClientIP 获取客户端的真实 IP 地址,优先从 X-Forwarded-For 或 X-Real-IP 头部获取, 如果没有则从请求的远程地址中提取

func ClientPublicIP

func ClientPublicIP(req *http.Request) string

ClientPublicIP 获取客户端的公网 IP 地址,排除本地地址

func ContentType

func ContentType(req *http.Request) string

ContentType 返回请求的 Content-Type 头部,并过滤掉参数部分

func HasLocalIPAddr

func HasLocalIPAddr(ip string) bool

HasLocalIPAddr 检查给定的 IP 字符串是否为本地地址(回环、链路本地单播或多播)

func HasLocalIp

func HasLocalIp(ip net.IP) bool

HasLocalIp 判断一个 net.IP 是否是本地地址

func IsWebsocket

func IsWebsocket(req *http.Request) bool

IsWebsocket 判断当前请求是否为 WebSocket 连接升级请求

func LongToIP

func LongToIP(i uint) (net.IP, error)

LongToIP 将无符号整数表示的 IPv4 地址转换为 net.IP 类型

func LongToIPString

func LongToIPString(i uint) (string, error)

LongToIPString 将无符号整数表示的 IPv4 地址转换为标准的点分十进制字符串格式

func RemoteIP

func RemoteIP(req *http.Request) string

RemoteIP 从 http.Request 中提取远程主机的 IP 地址

func StringToLong

func StringToLong(ip string) (uint, error)

StringToLong 将 IPv4 地址字符串转换为无符号整数表示形式

func ToLong

func ToLong(ip net.IP) (uint, error)

ToLong 将 net.IP 类型的 IPv4 地址转换为无符号整数表示形式

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL