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

Gzip file handling #1542

Merged
merged 8 commits into from
Oct 26, 2021
Merged

Gzip file handling #1542

merged 8 commits into from
Oct 26, 2021

Conversation

ghost
Copy link

@ghost ghost commented Oct 19, 2021

closes #1434

@ghost ghost requested a review from adamw October 19, 2021 08:38
@ghost ghost self-assigned this Oct 19, 2021
@@ -223,9 +242,13 @@ trait TapirStaticContentEndpoints {
*/
def resourceGetServerEndpoint[F[_]](prefix: EndpointInput[Unit])(
classLoader: ClassLoader,
resourcePath: String
resourcePath: String,
preGzipped: Boolean = false
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to change the name - I wouldn't guess what the preGzipped flag does ;) useGzippedIfAvailable?
Also, shouldn't we add this to the other variants of the methods?

case Some(v) =>
val option = v.split(",").headOption
val right =
if (option.exists(_.equals("gzip"))) Right(option)
Copy link
Member

Choose a reason for hiding this comment

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

I think we're filtering too early. Let's leave the acceptEncodingHeader parse whatever encodings are given (after all, it's an acceptEncodingHeader not gzipEncodingHeader) and filter later

serveRoute(resourceGetServerEndpoint[F](emptyInput)(loader, "test/r3.txt", preGzipped = true))
.use { port =>
emptyRequest
.get(uri"http://localhost:$port/test/r3.txt")
Copy link
Member

Choose a reason for hiding this comment

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

this should be r3 without .txt, or the gzipped version should be r3.txt.gz?

@adamw adamw merged commit 03996e2 into master Oct 26, 2021
@mergify mergify bot deleted the gzip-file-handling branch October 26, 2021 06:33
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.

Static content: implement gzip support for resources
1 participant