37 lines
641 B
Go

package main
import (
"flag"
"github.com/loveuer/nf"
"github.com/loveuer/nf/nft/log"
"time"
)
var (
address string
)
func init() {
flag.StringVar(&address, "address", ":80", "listen address")
flag.Parse()
}
func main() {
app := nf.New()
app.Get("/api/real-ip/available", func(c *nf.Ctx) error {
return c.JSON(nf.Map{"status": 200, "data": "available@" + time.Now().Format(time.RFC3339)})
})
app.Get("/api/real-ip/ip", func(c *nf.Ctx) error {
headers := c.Request.Header
return c.JSON(nf.Map{"status": 200, "data": nf.Map{
"ip": c.IP(),
"headers": headers,
}})
})
log.Fatal(app.Run(address).Error())
}