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

Support more HTTP methods, keep more details about HTTP matching failures #493

Merged
merged 15 commits into from
Nov 10, 2022

Conversation

kubukoz
Copy link
Member

@kubukoz kubukoz commented Oct 6, 2022

Closes #492.

@kubukoz
Copy link
Member Author

kubukoz commented Oct 6, 2022

http4s supports many more methods, maybe we should list them all? Or even support arbitrary strings for method names and try to parse them into http4s at derivation time? Smithy itself doesn't validate the string.

@kubukoz kubukoz requested a review from Baccata October 6, 2022 12:19
@Baccata
Copy link
Contributor

Baccata commented Oct 6, 2022

@kubukoz yeah we could make it an open-enumeration maybe ? Have a catch-all Other case ?

@kubukoz
Copy link
Member Author

kubukoz commented Oct 6, 2022

sounds alright - maybe I'll remove the ones that we don't explicitly use and move them into the open.

@kubukoz kubukoz marked this pull request as ready for review October 6, 2022 17:32
@kubukoz
Copy link
Member Author

kubukoz commented Oct 6, 2022

sounds alright - maybe I'll remove the ones that we don't explicitly use and move them into the open.

Did it for the new ones only - didn't want to break bincompat by dropping existing ones.

@kubukoz
Copy link
Member Author

kubukoz commented Oct 7, 2022

Not sure why removing the methods from smithy4s.internal (latest commit, f543008) didn't require an issue filter in MiMa...

@kubukoz kubukoz marked this pull request as draft October 7, 2022 16:50
@Baccata Baccata added this to the 0.17.0 milestone Oct 21, 2022
@kubukoz kubukoz changed the base branch from main to series/0.17 November 9, 2022 00:08
@kubukoz
Copy link
Member Author

kubukoz commented Nov 9, 2022

yo github wtf, I just pushed a merge from series/0.17 into this 🤔

@kubukoz kubukoz closed this Nov 9, 2022
@kubukoz kubukoz reopened this Nov 9, 2022
@kubukoz
Copy link
Member Author

kubukoz commented Nov 9, 2022

Looks like that did it...

@@ -231,8 +231,7 @@ lazy val scalacheck = projectMatrix
Dependencies.collectionsCompat.value,
Dependencies.Scalacheck.scalacheck.value
),
libraryDependencies ++= munitDeps.value,
testFrameworks += new TestFramework("weaver.framework.CatsEffect")
Copy link
Member Author

Choose a reason for hiding this comment

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

This is set by the project plugin

@@ -20,7 +20,7 @@ package internals

import smithy4s.schema._

private[smithy4s] class ErrorCodeSchemaVisitor(
private[http] class ErrorCodeSchemaVisitor(
Copy link
Member Author

Choose a reason for hiding this comment

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

More narrow visibility scope here - let me know if that makes sense

@kubukoz kubukoz marked this pull request as ready for review November 9, 2022 02:01
@kubukoz
Copy link
Member Author

kubukoz commented Nov 9, 2022

alright pls review @Baccata <3

@@ -53,6 +53,7 @@ class Smithy4sCli[Alg[_[_, _, _, _, _]], F[_]: MonadThrow](
): List[String] =
HttpEndpoint
.cast(endpoint)
.toOption
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: since we're throwing a few lines below, would it be worth it to throw here also rather than just swallow the error?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah lemme do that

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, I don't think so...

If HttpEndpoint.cast fails, that means the endpoint is not a HTTP one and this method should just return Nil. We're throwing iff HttpEndpoint.cast succeeds and the Http hint is missing, which would be a completely invalid state.

The purpose of protocolSpecificHelp is to generate a list of additional help strings based on... protocol-specific info 😅
so if you're implementing a CLI for a service that only exposes a CLI (and no HTTP interface), you want Nil here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do the same in Playground and I've been thinking about it recently: kubukoz/smithy-playground#139 - basically, if protocol-specific interpreters are allowed to prefix URLs, maybe we shouldn't trust the Http hint. Or HttpEndpoint, for that matter. Not sure what to think about this, but it's a separate problem from this PR I think.

@kubukoz kubukoz merged commit 14cd18a into series/0.17 Nov 10, 2022
@kubukoz kubukoz deleted the more-http-methods branch November 10, 2022 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not all HTTP methods are supported
3 participants