-
Notifications
You must be signed in to change notification settings - Fork 31
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
Allow Customizable API Route Prefix for Improved Integration Flexibility #9
Comments
Could you please elaborate your scenario a bit further in detail about 2 points:
|
Hi @pajama-coder , Here's some more detail about our integration scenario:
This approach gives us much flexibility in managing ZTM's API routes within our application's overall API structure. |
OK, so my understanding to this point is:
There's no issues to that. As to the integration method, I'm still confused about the motive for needing a path prefix. Since the listening port where ztm agent accepts requests is controlled all by ztm, there's no way to add in other APIs into the same port, so why is a path prefix needed here? My understanding is, if you have an out-facing API that combines ztm API with other apps, the only feasible way is to put a proxy in front of both APIs, listen on a different port and forward requests to either parties behind based on paths. As you foward requests to ztm-agent, you can do path converting however you like. That's why I don't quite get the need of a path prefix. |
@pajama-coder please read above environment carefully: @genedna said: "Integration Method: We're planning to embed ZTM directly into our Rust application by packaging Pipy as a Rust crate rather than running ZTM as a separate process." I'm not sure how he managed to embed C code within Rust and have all the processes bind to a single port, it's quite amazing. If there's only one network port, then this API indeed needs to have a suffix added. |
@xiaods It really doesn't matter how you package ztm with your app. What really matters here is how you wish ztm to be called. If you only call ztm from your app, whether in-process or inter-process, the interface won't be mistaken, thus, there's no point in renaming the API paths. The motive for a set of different API paths only makes sense when you plan to expose to the users a combined API including both ztm API and your own API, in which case you'll have to put a proxy in front of the two and let it forward requests based on path prefixes. This way, as the proxy does the forwarding, paths can be mapped to ztm API paths for ztm requests. So again, there's no point for ztm in supporting a different base path. |
I fully concur with your design approach; the crux of the issue lies in the misalignment of implementation strategies. |
@xiaods When ztm works like a lib or crate, it should go via a normal function call interface instead of HTTP, so 'base path' does make sense in that case. That is what I'm confused about. |
You found the answer, and I agree. |
Currently, ZTM's API routes are defined directly from the root path (e.g.,
/api/status
,/api/endpoints
). This works well when ZTM is used as a standalone application. However, it can lead to route conflicts when integrating ZTM into other applications that might have their API endpoints.Could you introduce a configuration option to set a custom prefix for all ZTM API routes? This prefix would be prepended to all existing routes.
Example:
If the prefix is set to
/ztm
, the routes would become:The text was updated successfully, but these errors were encountered: