Sha256: 9ca28e0b641097a29d90ab6768e5d0b8da42a88a6c532dfe3df5662fc7b389d8

Contents?: true

Size: 751 Bytes

Versions: 8

Compression:

Stored size: 751 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'
    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

8 entries across 8 versions & 1 rubygems

Version Path
solara-0.4.0 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.3.0 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.2.4 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.2.3 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.2.2 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.2.1 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.2.0 solara/lib/core/dashboard/handler/base_handler.rb
solara-0.1.0 solara/lib/core/dashboard/handler/base_handler.rb