require 'stringio'
session :off
- before_filter :check_availability
+ before_filter :check_write_availability
# to log:
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
class ApiController < ApplicationController
session :off
+ before_filter :check_read_availability, :except => [:capabilities]
after_filter :compress_output
#COUNT is the number of map requests to allow before exiting and starting a new process
end
end
- def check_availability
- if API_READONLY
+ def check_read_availability
+ if API_STATUS == :offline
+ response.headers['Error'] = "Database offline for maintenance"
+ render :nothing => true, :status => :service_unavailable
+ return false
+ end
+ end
+
+ def check_write_availability
+ if API_STATUS == :offline or API_STATUS == :readonly
response.headers['Error'] = "Database offline for maintenance"
render :nothing => true, :status => :service_unavailable
return false
session :off
before_filter :authorize, :only => [:create, :update, :delete]
- before_filter :check_availability, :only => [:create, :update, :delete]
+ before_filter :check_write_availability, :only => [:create, :update, :delete]
+ before_filter :check_read_availability, :except => [:create, :update, :delete]
after_filter :compress_output
def create
require 'xml/libxml'
session :off
+ before_filter :check_read_availability
after_filter :compress_output
def history
require 'xml/libxml'
session :off
+ before_filter :check_read_availability
after_filter :compress_output
def history
require 'xml/libxml'
session :off
+ before_filter :check_read_availability
after_filter :compress_output
def history
session :off
before_filter :authorize, :only => [:create, :update, :delete]
- before_filter :check_availability, :only => [:create, :update, :delete]
+ before_filter :check_write_availability, :only => [:create, :update, :delete]
+ before_filter :check_read_availability, :except => [:create, :update, :delete]
after_filter :compress_output
def create
class SwfController < ApplicationController
session :off
- before_filter :check_availability
+ before_filter :check_read_availability
# to log:
# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
session :off
before_filter :authorize, :only => [:create, :update, :delete]
- before_filter :check_availability, :only => [:create, :update, :delete]
+ before_filter :check_write_availability, :only => [:create, :update, :delete]
+ before_filter :check_read_availability, :except => [:create, :update, :delete]
after_filter :compress_output
def create
# inflect.uncountable %w( fish sheep )
# end
-# Set to true to put the API in read-only mode
-API_READONLY = false
+# Set to :readonly to put the API in read-only mode or :offline to
+# take it completely offline
+API_STATUS = :online
# Include your application configuration below
SERVER_URL = ENV['OSM_SERVER_URL'] || 'www.openstreetmap.org'