- api/common/v1 → api/open/v1,路由前缀 /api/common/v1 → /api/open/v1
- 契约层按子功能拆目录:api/open/v1/tools/{uuid,md5,random,time,ip}/index.go
- 控制器同步拆文件:internal/controller/open/{uuid,md5,random,time,ip}.go
- 命名规则(open 优于 common)与 tools 目录规则记入 AGENTS.md
- 冒烟测试:旧路由 404,新路由 5 端点全部通过
17 lines
449 B
Go
17 lines
449 B
Go
package open
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
|
ipapi "service.xpcool.com/api/open/v1/tools/ip"
|
|
"service.xpcool.com/common/tools/ip"
|
|
)
|
|
|
|
// IP returns the caller's IP and whether it is an internal address.
|
|
func (c *Controller) IP(ctx context.Context, req *ipapi.IPReq) (res *ipapi.IPRes, err error) {
|
|
clientIP := g.RequestFromCtx(ctx).GetClientIp()
|
|
return &ipapi.IPRes{IP: clientIP, Internal: ip.IsInternal(clientIP)}, nil
|
|
}
|