Sha256: a698471db367986dfd7f199bb19f6fcaa155572997ae79bfd1a02fec522a126c

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

class DoctorHandler < BaseHandler
    def mount
        @server.mount_proc('/brand/doctor') do |req, res|
            if req.request_method == 'GET'
                begin
                    query = CGI.parse(req.query_string)
                    brand_key = query['brand_key']&.first

                    if brand_key
                        doctor_result = run_doctor(brand_key)
                        res.status = 200
                        res.body = JSON.generate({ success: true, result: doctor_result })
                    else
                        res.status = 400
                        res.body = JSON.generate({ success: false, error: 'Missing brand_key parameter' })
                    end
                rescue StandardError => e
                    handle_error(res, e, "Error running doctor")
                end
            else
                method_not_allowed(res)
            end
            res.content_type = 'application/json'
        end
    end

    def run_doctor(brand_key)
        errors = SolaraManager.new.doctor(brand_key)
        {
            message: "Health check completed.",
            brand_key: brand_key,
            passed: errors.empty?,
            errors: errors
        }
    rescue StandardError => e
        Solara.logger.failure("Error running doctor: #{e.message}")
        raise
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
solara-0.7.4 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.7.3 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.7.2 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.7.1 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.7.0 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.6.0 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.5.0 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.4.0 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.3.0 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.2.4 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.2.3 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.2.2 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.2.1 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.2.0 solara/lib/core/dashboard/handler/doctor_handler.rb
solara-0.1.0 solara/lib/core/dashboard/handler/doctor_handler.rb