-
Notifications
You must be signed in to change notification settings - Fork 120
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
Refactor RouteOptions.toUrl #1314
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change bringing the possibility to pass either https://mapbox.com/
or https://mapbox.com
as baseUrl
and should work fine? I'm asking because
Line 25 in 7bc9a68
public static final String BASE_API_URL = "https://api.mapbox.com"; |
BTW code wise LGTM 👍
@Guardiola31337
|
@@ -2,6 +2,7 @@ apply plugin: 'java-library' | |||
|
|||
dependencies { | |||
api project(":services-geojson") | |||
api dependenciesList.okhttp3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Guardiola31337 do you think it's fine to bring okHttp
dependency to the models
model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great question. Yeah, ideally services-directions-models
doesn't have dependencies. We're including OkHttp in services-core
mapbox-java/services-core/build.gradle
Line 44 in 7bc9a68
api dependenciesList.retrofit |
mapbox-java/services-core/build.gradle
Line 51 in 7bc9a68
api dependenciesList.okhttp3Logging |
Can we workaround it somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I said we can't use java.net.URL
because it doesn't have handy methods to build URL, we will struggle with /
symbols anyway, I haven't found any workaround so use okhttp HttpUrl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's migrate toUrl
method to the service
module, smth like
class ServiceUtils {
public static String toUrl(RouteOption routeOptions) {
...
}
}
and deprecate current fun. This way we don't need okhttp dependency in the current module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kotlin extensions would look better 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote to move toUrl
to the service
module. Models
has to be as dumb as possible and assembling URLs based on fields is not what models should make
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LukasPaczos @Guardiola31337 vote please and I will continue with the approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to maintain the current version of RouteOptions::toUrl
anyway, we don't want to release a new breaking mapbox-java
release, so I would vote for this option. The method does not need to do any encoding, just a simple unencoded URL that HTTP clients can then interpret. We can migrate to string builders if that's easier and cover edge cases with tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, 2-1 wins stringBuilder
+ tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Late to the party but I'd vote StringBuilder
+ tests too 😅
044ccb1
to
5f1c388
Compare
I've fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
closes #1313
can't use
java.net.URL
case it doesn't have handy methods to build URL, so use okhttpHttpUrl
also some symbols were encoded:
; -> %3B
, -> %2C
it shouldn't be an issue, right?