You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to write a common directive that would provide info about requests similar to an access log but richer. I would find it really nice if the various sub-routes that satisfy the request could add additional information to the context - I tried using a Map[RequestContext, Map[String, Any]], but of course hit the request object changing throughout Route's "flow".
To write or extend the suite of directives more generally without needing to have one massive route, it would seem that changes would be required in the RequestContext object to carry around an additional payload which can be used to customize. To make it typesafe, perhaps the key could be an instance of something that carries the desired value type - using an instance rather than string, and some type of "identityHashMap" for lookup could reduce collisions that String keys might have.
The text was updated successfully, but these errors were encountered:
I'm not sure I understand your exact use case, but I think this might be covered by #1500: as noted there, you can currently add custom headers to a request/response to pass along extra information with the message. Does that apply? If not, could you explain your use case a bit more?
Well… I was trying to design an app where several classes could provide their own routes and to have an outer directive that logged whatever it could find about the request/response. I was hoping that individual routes could add info to the context and that context could be examined by the logger to write out whatever seemed reasonable. Instead, at current PR, it needs to call one of several functions that return a Directive0 from the info that's created/extracted etc from the routes which seems harder to manage than having one directive. I'll look at #1500 and see if that gives me access to dynamic things (i.e. not just strings, but maybe a Map[String, String], e.g. that can be adjusted throughout each request)
I was trying to write a common directive that would provide info about requests similar to an access log but richer. I would find it really nice if the various sub-routes that satisfy the request could add additional information to the context - I tried using a
Map[RequestContext, Map[String, Any]]
, but of course hit the request object changing throughout Route's "flow".To write or extend the suite of directives more generally without needing to have one massive route, it would seem that changes would be required in the
RequestContext
object to carry around an additional payload which can be used to customize. To make it typesafe, perhaps the key could be an instance of something that carries the desired value type - using an instance rather than string, and some type of "identityHashMap" for lookup could reduce collisions thatString
keys might have.The text was updated successfully, but these errors were encountered: