Skip to content

Middleware (hooks) #29

@cyberhck

Description

@cyberhck

Hi there,
I'm using this project for my android project. And I wanted to implement a JWT token middleware which will automatically refresh a JWT if it was expired and then continue with the response. Coming across the readme, I found out that beforeSend and afterReceive are planned and are in Todo.

Coming from Golang/TypeScript world, I'd suggest something like this:

webb.AddMiddlware(jsonMiddleware)

Middleware implements an interface with method handle() which receives the original request and the next handler function

Now middleware can choose to either call the next or entirely skip, or maybe even modify the original request before continueing. Let me know if that makes sense 🙂

This one will totally resolve the necessity of the following todos:

  • decorator/interceptor beforeSend - provide hooks to manipulate request before send
  • decorator/interceptor afterReceive - provide hooks to manipulate raw response after receiving it

Let me know if you'll be willing to accept PRs :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions