예제 #1
0
func getGeoIPRecord(ctx *app.Context) *geoip.Record {
	if rec, _ := ctx.Get(recordKey).(*geoip.Record); rec != nil {
		return rec
	}
	g, _ := ctx.App().Get(geoIPKey).(*geoip.GeoIP)
	if g == nil {
		log.Warning("no GeoIP data loaded - did you call geoip.Load()?")
		return nil
	}
	rec, _ := g.Lookup(ctx.RemoteAddress())
	ctx.Set(recordKey, rec)
	return rec
}