Skip to content

How to add constraints on routes? #1934

Discussion options

You must be logged in to vote

I was on my way to configure NGINX to directly serve static files without passing the request to Lucky. But I realise that I can configure Lucky to handle static files before routes simply by moving RouteHandler after StaticFileHandler in middleware and setting fallthrough to true.

# src/app_server.cr
class AppServer < Lucky::BaseAppServer
  def middleware : Array(HTTP::Handler)
    [
      Lucky::RequestIdHandler.new,
      Lucky::ForceSSLHandler.new,
      Lucky::HttpMethodOverrideHandler.new,
      Lucky::LogHandler.new,
      Lucky::ErrorHandler.new(action: Errors::Show),
      Lucky::RemoteIpHandler.new,
-     Lucky::RouteHandler.new,
      Lucky::StaticCompressionHandler.new("./publ…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jwoertink
Comment options

Answer selected by cristian-lsdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants