Disable handlers for disabled features

This commit is contained in:
Martin Polden
2018-02-10 17:52:55 +01:00
parent 8112536125
commit 215cce290c
3 changed files with 68 additions and 17 deletions

View File

@ -9,6 +9,7 @@ import (
type Database interface {
Country(net.IP) (Country, error)
City(net.IP) (string, error)
IsEmpty() bool
}
type Country struct {
@ -25,6 +26,7 @@ type empty struct{}
func (d *empty) Country(ip net.IP) (Country, error) { return Country{}, nil }
func (d *empty) City(ip net.IP) (string, error) { return "", nil }
func (d *empty) IsEmpty() bool { return true }
func Empty() Database { return &empty{} }
@ -87,3 +89,7 @@ func (g *geoip) City(ip net.IP) (string, error) {
}
return "", nil
}
func (g *geoip) IsEmpty() bool {
return g.country != nil || g.city != nil
}