Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Compitable with context.Context middlewares #40

Open
lunny opened this issue May 7, 2017 · 0 comments
Open

Compitable with context.Context middlewares #40

lunny opened this issue May 7, 2017 · 0 comments

Comments

@lunny
Copy link
Owner

lunny commented May 7, 2017

Action is an interface in an middleware and context.Context is also an interface. Their are some similar feature between Action and context.Context. In tango, we use assert to get the info from Action, in context.Context, it's also a regular usage get info via assert.

func (ctx *tango.Ctx) {
     if sess, ok := ctx.Action().(Sessioner); ok {
           // do something
    }
}
func (resp http.ResponseWriter, req *http.Request) {
    if sess, ok := req.Context().(Sessioner); ok {
          // do something 
   }
}

So that maybe all the tango's middlewares could be changed slightly to apply in http.Handler.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant