-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconfig.cr
More file actions
55 lines (47 loc) · 1.66 KB
/
Copy pathconfig.cr
File metadata and controls
55 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Application dependencies
require "action-controller"
require "./constants"
# Application code
require "./controllers/application"
require "./controllers/*"
require "./models/*"
# Server required after application controllers
require "action-controller/server"
module App
# Configure logging (backend defined in constants.cr)
if running_in_production?
log_level = ::Log::Severity::Info
::Log.setup "*", :warn, LOG_BACKEND
else
log_level = ::Log::Severity::Debug
::Log.setup "*", :info, LOG_BACKEND
end
::Log.builder.bind "action-controller.*", log_level, LOG_BACKEND
::Log.builder.bind "#{NAME}.*", log_level, LOG_BACKEND
# Filter out sensitive params that shouldn't be logged
filter_params = ["password", "bearer_token"]
keeps_headers = ["X-Request-ID"]
# Add handlers that should run before your application
ActionController::Server.before(
ActionController::ErrorHandler.new(running_in_production?, keeps_headers),
ActionController::LogHandler.new(filter_params),
HTTP::CompressHandler.new
)
# Optional support for serving of static assests
if File.directory?(STATIC_FILE_PATH)
# Optionally add additional mime types
::MIME.register(".yaml", "text/yaml")
# Check for files if no paths matched in your application
ActionController::Server.before(
::HTTP::StaticFileHandler.new(STATIC_FILE_PATH, directory_listing: false)
)
end
# Configure session cookies
# NOTE:: Change these from defaults
ActionController::Session.configure do |settings|
settings.key = COOKIE_SESSION_KEY
settings.secret = COOKIE_SESSION_SECRET
# HTTPS only:
settings.secure = running_in_production?
end
end