module AlittleLess::Util
Public Instance Methods
add_default_cors_headers()
click to toggle source
# File lib/a_little_less/util.rb, line 48 def add_default_cors_headers @req.resp.headers.merge!( 'Access-Control-Allow-Origin' => '*', 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS', 'Access-Control-Max-Age' => '1728000' ) end
error_422(body)
click to toggle source
# File lib/a_little_less/util.rb, line 28 def error_422 body status 422 with body end
http_options?()
click to toggle source
HTTP CORS
# File lib/a_little_less/util.rb, line 40 def http_options? @req.http_method == :options end
http_origin_allowed?()
click to toggle source
# File lib/a_little_less/util.rb, line 44 def http_origin_allowed? true end
not_found()
click to toggle source
# File lib/a_little_less/util.rb, line 19 def not_found status 404 end
params()
click to toggle source
Response
# File lib/a_little_less/util.rb, line 5 def params @req.params end
redir_301(url)
click to toggle source
# File lib/a_little_less/util.rb, line 33 def redir_301 url @req.resp.headers['Location'] = url @req.resp.status = 301 end
send_file(file)
click to toggle source
# File lib/a_little_less/util.rb, line 9 def send_file file @req.resp.headers['X-Sendfile'] = file nil end
set_options_response()
click to toggle source
# File lib/a_little_less/util.rb, line 56 def set_options_response @req.resp.headers.merge!( 'Access-Control-Allow-Headers' => 'Accept, Cache-Control, Content-Type, X-Requested-With', 'Content-Type' => 'text/plain' ) @req.resp.body = '' end
status(code)
click to toggle source
# File lib/a_little_less/util.rb, line 14 def status code @req.resp.status = code nil end
with(body)
click to toggle source
# File lib/a_little_less/util.rb, line 23 def with body @req.resp.body = body nil end