go-res icon indicating copy to clipboard operation
go-res copied to clipboard

Handler bubbling

Open jirenius opened this issue 5 years ago • 2 comments

Issue

In case a res.Handler does not contain a handler method for a given request, it should bubble up to the next best res.Handler match.

Example

s := res.Service("test")
s.Handle("model",
   res.GetModel(func(r res.ModelRequest) {
      r.Model(json.RawMessage(`{"foo":"bar"}`)
   }),
)
s.Handle(">", res.Access(res.AccessGranted))

An access request, access.test.model, should be handled by the handler for the wildcard ">" as the "model" handler has does not have an access handler method.

jirenius avatar Dec 16 '19 14:12 jirenius

+1

remyduthu avatar Feb 25 '22 11:02 remyduthu

I would really like to help you add this feature. I would like to know if the goal is to modify the add() method of the Mux type?

https://github.com/jirenius/go-res/blob/master/mux.go#L270-L288

remyduthu avatar Mar 05 '22 18:03 remyduthu