baked_file_handler
Version, currently 0.1.55 versions
github.com/ralsina/baked_file_handler
No description declared in shard.yml.
3 stars
6 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
baked_file_handler:
github: ralsina/baked_file_handler
version: ~> 0.1.5Then run:
shards installshard.yml
- Crystal
>= 1.16.3- License
- MIT
- Author
- Roberto Alsina
Dependencies
Development Dependencies
- kemal*github: kemalcr/kemaldev
- baked_file_system*github: ralsina/baked_file_systemdev
README
baked_file_handler
A Kemal handler for serving files baked into the application.
Installation
-
Add the dependency to your
shard.yml:dependencies: baked_file_handler: github: ralsina/baked_file_handler -
Run
shards install
Usage
require "kemal"
require "baked_file_system"
# Example BakedFileSystem class
class MyAssets
extend BakedFileSystem
bake_folder "./public_assets"
end
add_handler BakedFileHandler::BakedFileHandler.new(MyAssets)
Kemal.run
Compression Support
The handler automatically serves compressed versions of files when available and supported by the client.
How it works:
- Check the
Accept-Encodingheader for supported compression methods - Look for compressed versions of files with
.br(Brotli) or.gz(gzip) extensions - Serve the compressed version with appropriate
Content-Encodingheader - Fall back to uncompressed files if no compressed version exists
Priority:
- Brotli (
.br) - preferred when client supports it - Gzip (
.gz) - used when client supports gzip but not Brotli - Uncompressed - fallback when no compression is supported
Example:
If you have both style.css and style.css.gz baked into your assets:
- Request with
Accept-Encoding: gzipwill servestyle.css.gzwithContent-Encoding: gzip - Request with no compression support will serve
style.cssnormally
Development
I don't expect this need much further development. In any case, it's simple enough code :-)
Contributing
- Fork it (https://github.com/ralsina/baked_file_handler/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Roberto Alsina - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.5- Tagged
- Dec 26, 2025
- Commit
e540b7ed5769- Crystal
>= 1.16.3- Indexed
- yes
Dependents
Repository
github.com/ralsina/baked_file_handler
Metadata
- Created
- Aug 16, 2026
- Updated
- Sep 9, 2026
- Synced
- Sep 9, 2026
- Versions
- 5