Reputation: 755
Is there a proper and/or standard way to parse-build a URI together?
Say I have a project that has a lot of differing URIs and legacy-code that is not being allowed to be changed. I'm to both keep the current system working while accommodating and standardizing the process of how our URLs are being handled going forward. I am not able or in-a-position to be changing the key-values provided or giving feedback to the configuration end-users. And due to structures outside of my locus-of-control, I'm unable to apply a standard behavior-and/or-expectation upon these people.
Person-1 provides the Spring Configuration in a application.yaml
like so:
scheme: https
host: localhost
port: port
path: path
product:
id: product.id
I can use a URI-Builder to make this easier to verify is done correctly:
UriComponentsBuilder.newInstance().scheme(scheme).host(host).port(port).path(path).path(product.id).build();
Which comes out as: https://localhost:8080/path/product.id
, good.
However, Person-2 is different. They effectively write their OS environment variables:
scheme: https
host: https://web.site.company.com.local/
path: /path/
path_please_append_thanks: /path_please_append_thanks/
product:
id: /product.id/
Now the first method doesn't work.
The result would come out like: https://https://web.site.company.com.local/ //path///path_please_append_thanks///product.id/
.
Okay, I can check-replace/remove slashes and check for https://
already being appended.
Person-3 does something different in K8s. I cannot see what they did but told what's seen is failing. I can only guess and/or am-told theirs look something like:
#scheme: https
host: this.looks.weird/but.its.fine
path: /this/is/totally/normal/we_want_this
path_please_append_thanks: /path_please_append_thanks/real/production/now
product:
id: //product.we.know.is.real.because.this.weird.format.makes.us.know.others.cannot.parse/id.product
Okay. Now what.
I definitely can and have made something that is customized to code for handling these idiosyncrasies. But, I think that I cannot be the first to run into this issue and is something that has written a tool for already. I just don't know where to look and so far the phrasing I've used to search the internet hasn't returned back a standard-and-scalable solution to handle situations like these. Is there a tool, process, and/or optionals that I'm overlooking or not aware of to handle situations like these?
Upvotes: 0
Views: 34