diff options
author | haturatu <taro@eyes4you.org> | 2025-02-22 23:20:55 +0900 |
---|---|---|
committer | haturatu <taro@eyes4you.org> | 2025-02-22 23:20:55 +0900 |
commit | 9345907a5c1737c6c2c1f8eba52a568035b08493 (patch) | |
tree | 50f0c68436e4eba8e7a72cf9876a577d0c4c6340 /cmd/ponzu/vendor/github.com/nilslice/jwt/README.md | |
parent | a9cdbc4e7fbdd14922ef5c96cc7a285b153bf947 (diff) |
fix: all hange s\/github.com\/ponzu-cms/github.com\/haturatu\/g
Diffstat (limited to 'cmd/ponzu/vendor/github.com/nilslice/jwt/README.md')
-rw-r--r-- | cmd/ponzu/vendor/github.com/nilslice/jwt/README.md | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md b/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md deleted file mode 100644 index a384dd1..0000000 --- a/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# JWT - -### Usage - $ go get github.com/nilslice/jwt - -package jwt provides methods to create and check JSON Web Tokens. It only implements HMAC 256 encryption and has a very small footprint, ideal for simple usage when authorizing clients - -```go - package main - - import ( - auth "github.com/nilslice/jwt" - "fmt" - "net/http" - "strings" - ) - - func main() { - http.HandleFunc("/auth/new", func(res http.ResponseWriter, req *http.Request) { - claims := map[string]interface{}{"exp": time.Now().Add(time.Hour * 24).Unix()} - token, err := auth.New(claims) - if err != nil { - http.Error(res, "Error", 500) - return - } - res.Header().Add("Authorization", "Bearer "+token) - - res.WriteHeader(http.StatusOK) - }) - - http.HandleFunc("/auth", func(res http.ResponseWriter, req *http.Request) { - userToken := strings.Split(req.Header.Get("Authorization"), " ")[1] - - if auth.Passes(userToken) { - fmt.Println("ok") - } else { - fmt.Println("no") - } - }) - - http.ListenAndServe(":8080", nil) - } -``` |