Removed unnecessary middleware
This commit is contained in:
parent
0204958e81
commit
5476753520
1
main.go
1
main.go
@ -78,7 +78,6 @@ func configure(app *aero.Application) *aero.Application {
|
|||||||
app.Use(middleware.Log())
|
app.Use(middleware.Log())
|
||||||
app.Use(middleware.Session())
|
app.Use(middleware.Session())
|
||||||
app.Use(middleware.UserInfo())
|
app.Use(middleware.UserInfo())
|
||||||
app.Use(middleware.IPToHost())
|
|
||||||
|
|
||||||
// API
|
// API
|
||||||
api := api.New("/api/", arn.DB)
|
api := api.New("/api/", arn.DB)
|
||||||
|
@ -4,21 +4,11 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
|
||||||
cache "github.com/patrickmn/go-cache"
|
cache "github.com/patrickmn/go-cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ipToHosts = cache.New(60*time.Minute, 30*time.Minute)
|
var ipToHosts = cache.New(60*time.Minute, 30*time.Minute)
|
||||||
|
|
||||||
// IPToHost middleware tries to find domain names for the given IP.
|
|
||||||
func IPToHost() aero.Middleware {
|
|
||||||
return func(ctx *aero.Context, next func()) {
|
|
||||||
next()
|
|
||||||
|
|
||||||
go findHostsForIP(ctx.RealIP())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetHostsForIP returns all host names for the given IP (if cached).
|
// GetHostsForIP returns all host names for the given IP (if cached).
|
||||||
func GetHostsForIP(ip string) []string {
|
func GetHostsForIP(ip string) []string {
|
||||||
hosts, found := ipToHosts.Get(ip)
|
hosts, found := ipToHosts.Get(ip)
|
||||||
|
Loading…
Reference in New Issue
Block a user