Skip to content

Make JWT helpers extendable

Pre-release
Pre-release
Compare
Choose a tag to compare
@tanner0101 tanner0101 released this 30 Jul 16:36
03cb638
This patch was authored and released by @tanner0101.

This change publicizes internal properties on JWT helpers to make them more easily extendable (#131, fixes #125).

// Custom extension
extension Request.JWT {
    // Methods now have access to the request
    func myVerifier() {
        print(self._request) // Current request
    }
}

// Usage
req.jwt.myVerifier()

The property names have been prefixed with _ to prevent autocomplete from suggesting things like:

req.jwt.request

⚠️ Note: Application.JWT and Request.JWT's initializers have been removed. These were redundant and can be declared much more concisely:

- Application.JWT(application: app)
+ app.jwt
- Request.JWT(request: req)
+ req.jwt