diff --git a/_examples/auth/jwt/main.go b/_examples/auth/jwt/main.go index 77f9648f..2c31091f 100644 --- a/_examples/auth/jwt/main.go +++ b/_examples/auth/jwt/main.go @@ -20,6 +20,10 @@ func main() { // // Use the `jwt.New` instead for more flexibility, if necessary. j := jwt.HMAC(15*time.Minute, "secret", "itsa16bytesecret") + // By default it extracts the token from url parameter "token={token}" + // and the Authorization Bearer {token} header. + // You can also take token from JSON body: + // j.Extractors = append(j.Extractors, jwt.FromJSON) app := iris.New() app.Logger().SetLevel("debug") @@ -59,7 +63,7 @@ func main() { return } - ctx.Writef("Claims: %#+v\n", claims) + ctx.Writef("Username: %s\nExpires at: %s\n", claims.Username, claims.Expiry.Time()) }) } diff --git a/core/netutil/ip_test.go b/core/netutil/ip_test.go index 4451b4fa..ac4eb4aa 100644 --- a/core/netutil/ip_test.go +++ b/core/netutil/ip_test.go @@ -1,35 +1,34 @@ package netutil import ( - "net" "testing" ) func TestIP(t *testing.T) { privateRanges := []IPRange{ { - Start: net.ParseIP("10.0.0.0"), - End: net.ParseIP("10.255.255.255"), + Start: "10.0.0.0", + End: "10.255.255.255", }, { - Start: net.ParseIP("100.64.0.0"), - End: net.ParseIP("100.127.255.255"), + Start: "100.64.0.0", + End: "100.127.255.255", }, { - Start: net.ParseIP("172.16.0.0"), - End: net.ParseIP("172.31.255.255"), + Start: "172.16.0.0", + End: "172.31.255.255", }, { - Start: net.ParseIP("192.0.0.0"), - End: net.ParseIP("192.0.0.255"), + Start: "192.0.0.0", + End: "192.0.0.255", }, { - Start: net.ParseIP("192.168.0.0"), - End: net.ParseIP("192.168.255.255"), + Start: "192.168.0.0", + End: "192.168.255.255", }, { - Start: net.ParseIP("198.18.0.0"), - End: net.ParseIP("198.19.255.255"), + Start: "198.18.0.0", + End: "198.19.255.255", }, }