Sha256: 9ea48a823ed09ef27169e2c82b4f7f51457f3ea6b400dd00b9c0c84738c1a5d6

Contents?: true

Size: 786 Bytes

Versions: 7

Compression:

Stored size: 786 Bytes

Contents

class BaseHandler
    def initialize(server, dashboard_server)
        @server = server
        @dashboard_server = dashboard_server
    end

    def mount
        raise NotImplementedError, "Subclasses must implement the 'mount' method"
    end

    protected

    def handle_error(res, error, message, status = 500)
        Solara.logger.failure("#{message}: #{error.message}")
        res.status = status
        res.body = JSON.generate({ success: false, error: "#{message}: #{error.message}" })
        res.content_type = 'application/json'
        Solara.logger.error(error)
    end

    def method_not_allowed(res)
        res.status = 405
        res.body = JSON.generate({ success: false, error: 'Method Not Allowed' })
        res.content_type = 'application/json'
    end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solara-0.7.4 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.7.3 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.7.2 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.7.1 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.7.0 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.6.0 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.5.0 solara/lib/core/dashboard/handler/base_handler.rb