Sha256: 088897cd816bb310808fe548cf67e11845101c5aac1d3d0512e4ea1f19696385

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

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

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

    def get_brand_aliases(brand_key)
        AliasGeneratorManager.aliases_json
    rescue StandardError => e
        Solara.logger.failure("Error getting brand aliases: #{e.message}")
        raise
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solara-0.2.0 solara/lib/core/dashboard/handler/brand_alisases_handler.rb
solara-0.1.0 solara/lib/core/dashboard/handler/brand_alisases_handler.rb