mardi 21 avril 2020

How can i pass custom type in handler functions? Is that even possible?

I have a web app that processes web requests and does some job with local (unix) sockets.

At this time it has single unix-socket connection and with each web request processing app writes/reads something to/from socket.

I was going to implement multiple socket connections. So it looks like this:

req path: /{id}/path/to/resource

where {id} determines which unix socket will be used

When program starts its not possible to know how many sockets will be used since user may create new ones.

My idea was to create map that holds unix socket connections and use middleware function to pass specific unix socket to handler based on uri so that handler function will do same stuff with different sockets. How can i pass my custom data between middlewares and handle functions?




Aucun commentaire:

Enregistrer un commentaire