Skip to content

Commit

Permalink
Improve readme formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aldas committed Nov 21, 2024
1 parent 6477ba4 commit 0cba7e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ e.GET("/", func(c echo.Context) error {

## IMPORTANT: Integration Testing with JWT Library

Ensure that your project includes at least one integration test to detect changes in major versions of the JWT library early.
This is crucial because type assertions like token := c.Get("user").(*jwt.Token) may fail silently if the imported version of the JWT library (e.g., import "github.com/golang-jwt/jwt/v5") differs from the version used internally by dependencies (e.g., echo-jwt may now use v6). Such discrepancies can lead to invalid casts, causing your handlers to panic or throw errors. Integration tests help safeguard against these version mismatches.
Ensure that your project includes at least one integration test to detect changes in major versions of the `golang-jwt/jwt` library early.
This is crucial because type assertions like `token := c.Get("user").(*jwt.Token)` may fail silently if the imported version of the JWT library (e.g., `import "github.com/golang-jwt/jwt/v5"`) differs from the version used internally by dependencies (e.g., echo-jwt may now use `v6`). Such discrepancies can lead to invalid casts, causing your handlers to panic or throw errors. Integration tests help safeguard against these version mismatches.

```go
func TestIntegrationMiddlewareWithHandler(t *testing.T) {
Expand All @@ -77,7 +77,7 @@ func TestIntegrationMiddlewareWithHandler(t *testing.T) {
SigningKey: []byte("secret"),
}))

// use handler that gets token from context to fail your CI flow when JWT library version changes
// use handler that gets token from context to fail your CI flow when `golang-jwt/jwt` library version changes
// a) `token, ok := c.Get("user").(*jwt.Token)`
// b) `token := c.Get("user").(*jwt.Token)`
e.GET("/example", exampleHandler)
Expand Down

0 comments on commit 0cba7e7

Please sign in to comment.