-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use for non-http #67
Comments
Not out of the box, but pretty much all the logic you want is contained in With the caveat that I haven't tried it, I think something like this should work: First, instantiate the root of the tree.
Then add routes to it.
Here I'm just calling it with the Lines 96 to 106 in a454a10
And later look it up (removing the leading slash if there is one)
Then process the results.
The returned wildcard parameters are in a slice by default. The code to make these into a map with named parameters, if you want, is Lines 188 to 201 in a454a10
These snippets don't take into account the trailing slash behavior, so if you care about that you can find the relevant parts throughout the code base by searching for You would also want to change the various references to HandlerFunc to be whatever function prototype you want, and depending on how much work you want to do, maybe remove all the HTTP method specific stuff in Hope this helps! |
how would I add a mutex so i can modify the routes at runtime? |
Same as anything else that needs thread safety. Wrap the calls to add new routes and the calls to search with an RWMutex or whatever you deem most appropriate. The router already has an option to do this so you can see how it does it by looking through the code. |
thank you @dimfeld |
Is there a way to use this for non-http scenarios. I only need the path routing implementation. i.e. string -> parse -> call a function based on arguments in "route" path
The text was updated successfully, but these errors were encountered: