diff options
Diffstat (limited to 'src/app_server.cr')
-rw-r--r-- | src/app_server.cr | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/app_server.cr b/src/app_server.cr new file mode 100644 index 0000000..8ec16c3 --- /dev/null +++ b/src/app_server.cr @@ -0,0 +1,26 @@ +class AppServer < Lucky::BaseAppServer + # Learn about middleware with HTTP::Handlers: + # https://luckyframework.org/guides/http-and-routing/http-handlers + 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("./public", file_ext: "gz", content_encoding: "gzip"), + Lucky::StaticFileHandler.new("./public", fallthrough: false, directory_listing: false), + Lucky::RouteNotFoundHandler.new, + ] of HTTP::Handler + end + + def protocol + "http" + end + + def listen + server.listen(host, port, reuse_port: false) + end +end |