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

Introduce asset endpoints #1017

Merged
merged 4 commits into from
Nov 14, 2018
Merged

Introduce asset endpoints #1017

merged 4 commits into from
Nov 14, 2018

Conversation

vkostyukov
Copy link
Collaborator

@vkostyukov vkostyukov commented Oct 30, 2018

Turns out after we deprecated Twitter Futures in the mapper it became problematic to serve static files (although people generally not supposed to do that) with Readers.

This PR leverages cats-effect Resource to read Java resources and serve them as a static content.

An example:

Bootstrap
  .serve[Application.Javascript](Endpoint[IO].classpathAsset("/script.js"))

@vkostyukov vkostyukov force-pushed the vk/resource branch 2 times, most recently from 8792806 to a4e8426 Compare October 30, 2018 23:56
@codecov-io
Copy link

codecov-io commented Oct 31, 2018

Codecov Report

Merging #1017 into master will increase coverage by 0.54%.
The diff coverage is 82.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1017      +/-   ##
==========================================
+ Coverage   84.28%   84.83%   +0.54%     
==========================================
  Files          48       49       +1     
  Lines         910      956      +46     
  Branches       57       67      +10     
==========================================
+ Hits          767      811      +44     
- Misses        143      145       +2
Impacted Files Coverage Δ
core/src/main/scala/io/finch/Trace.scala 92.85% <100%> (+2.85%) ⬆️
core/src/main/scala/io/finch/EndpointModule.scala 83.01% <50%> (-2.7%) ⬇️
core/src/main/scala/io/finch/Endpoint.scala 72.89% <66.66%> (-0.66%) ⬇️
...re/src/main/scala/io/finch/endpoint/endpoint.scala 93.75% <93.75%> (ø)
core/src/main/scala/io/finch/Output.scala 95.65% <0%> (+0.78%) ⬆️
core/src/main/scala/io/finch/Input.scala 100% <0%> (+9.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f5006f...15eb10b. Read the comment docs.

@rpless
Copy link
Collaborator

rpless commented Nov 4, 2018

I like this. For the name, maybe classpathResource or resourceFromClasspath could work? I also like liftResource.

My only other thought is maybe we should replace the example of serving static files in the cookbook with this.

@vkostyukov
Copy link
Collaborator Author

I like this. For the name, maybe classpathResource or resourceFromClasspath could work? I also like liftResource.

My only other thought is maybe we should replace the example of serving static files in the cookbook with this.

Yes, I need to update the cookbook. Also I like your classpath idea.

@vkostyukov vkostyukov changed the title Introduce Endpoint.resource Introduce asset endpoints Nov 13, 2018
@vkostyukov vkostyukov merged commit fdf8987 into master Nov 14, 2018
@vkostyukov vkostyukov deleted the vk/resource branch November 14, 2018 05:22
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.

3 participants