Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 872 Bytes

file-download.md

File metadata and controls

35 lines (26 loc) · 872 Bytes

File Download

This recipe will help you to setup a static file handler in your application.

{% hint style="warning" %} First you need an amber project generated with Amber CLI or from scratch. {% endhint %}

{% code-tabs %} {% code-tabs-item title="config/application.cr" %}

Amber::Server.configure do |app|
  # All static content will run these transformations
  pipeline :static do
    plug Amber::Pipe::PoweredByAmber.new
    plug Amber::Pipe::Error.new
    plug Amber::Pipe::Static.new("./public")
  end

  routes :static do
    get "/*", Amber::Controller::Static, :index
  end
end

{% endcode-tabs-item %} {% endcode-tabs %}

Also see pipelines.

{% hint style="success" %} This code is already included on projects generated by Amber CLI {% endhint %}