userver icon indicating copy to clipboard operation
userver copied to clipboard

feat userver: allow creating custom implicit options

Open trenin17 opened this issue 1 year ago • 2 comments
trafficstars

Usage example:

class CustomImplicitOptions final : public userver::server::handlers::ImplicitOptions {
 public:
    CustomImplicitOptions(const userver::components::ComponentConfig& config,
                          const userver::components::ComponentContext& context,
                          bool is_monitor = false) : ImplicitOptions(config, context, is_monitor) {}

    std::string HandleRequestThrow(const userver::server::http::HttpRequest& request,
                                   userver::server::request::RequestContext& context) const override {
    request.GetHttpResponse().SetHeader(static_cast<std::string>("Access-Control-Allow-Origin"), "*");
    request.GetHttpResponse().SetHeader(static_cast<std::string>("Access-Control-Allow-Headers"), "*");

    return ImplicitOptions::HandleRequestThrow(request, context);
}
};

trenin17 avatar Jan 13 '24 22:01 trenin17

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Jan 13 '24 22:01 github-actions[bot]

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/

trenin17 avatar Jan 13 '24 22:01 trenin17