Skip to content
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

Make type Scheme follow the specs #2490

Conversation

FabioPinheiro
Copy link
Contributor

@FabioPinheiro FabioPinheiro commented Oct 18, 2023

Make type Scheme more flexible
Fix for #2489 Follow the specs:

I'm just concerned about efficiency and keep the source code interface as similar as possible.

@CLAassistant
Copy link

CLAassistant commented Oct 18, 2023

CLA assistant check
All committers have signed the CLA.

@FabioPinheiro
Copy link
Contributor Author

Is there benchmark that I can run here?


/**
* Decodes a string to an Option of Scheme. Returns None in case of
* null/non-valid Scheme
*
* Scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about add a regex for this.
Also make sure everything is lowercase.

But I was concerned about efficient. Should we create a new method for that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we should check the validity here. But I think we should ignore casing

@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (ff8563a) 64.95% compared to head (2b46f7a) 65.01%.
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2490      +/-   ##
==========================================
+ Coverage   64.95%   65.01%   +0.05%     
==========================================
  Files         136      136              
  Lines        7197     7208      +11     
  Branches     1296     1300       +4     
==========================================
+ Hits         4675     4686      +11     
  Misses       2522     2522              
Files Coverage Δ
zio-http/src/main/scala/zio/http/ZClient.scala 48.17% <100.00%> (ø)
...la/zio/http/netty/client/NettyConnectionPool.scala 90.90% <100.00%> (ø)
zio-http/src/main/scala/zio/http/Scheme.scala 86.66% <88.46%> (+17.10%) ⬆️
zio-http/src/main/scala/zio/http/URL.scala 82.64% <64.00%> (-1.98%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

zio-http/src/main/scala/zio/http/ZClient.scala Outdated Show resolved Hide resolved
zio-http/src/main/scala/zio/http/URL.scala Outdated Show resolved Hide resolved
zio-http/src/main/scala/zio/http/Scheme.scala Outdated Show resolved Hide resolved
zio-http/src/main/scala/zio/http/Scheme.scala Outdated Show resolved Hide resolved

/**
* Decodes a string to an Option of Scheme. Returns None in case of
* null/non-valid Scheme
*
* Scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we should check the validity here. But I think we should ignore casing

@FabioPinheiro FabioPinheiro force-pushed the fix/issue2489-Make_type_Scheme_following_the_specs branch from c9151cc to 2b46f7a Compare October 28, 2023 20:25
FabioPinheiro added a commit to FabioPinheiro/scala-did that referenced this pull request Oct 28, 2023
Add environment variable (USE_SNAPSHOTS=true) to control the build
Update zio-http to 3.0.0-RC3-SNAPSHOT (Fix for CORS)
zio-http with CORS fix when origin: chrome-extension
See zio/zio-http#2490
@@ -78,4 +89,15 @@ object Scheme {
case object WS extends Scheme

case object WSS extends Scheme

/**
* @param scheme
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would actually happen, if this is http(s)/ws(s)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a question of pattern matching.

We are allowing two representations for the same value. (Scheme.HTTP and Scheme.Custom("http"))
Since the construction method is public.
But I see this pattern is being used everywhere in zio-http so it's a more general problem

One solution would be to make it private and the only way to create Custom is with the Scheme's method def decode(scheme: String).
This would make it a bit more type-safe. Instead of being on the documentation

@987Nabil 987Nabil merged commit 33512bc into zio:main Nov 24, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants