public:
static constexpr std::string_view kName = "action-client";
: ComponentBase{config, context},
service_url_(config["service-url"].As<std::string>()),
auto CreateHttpRequest(std::string action) const {
}
type: object
description: My dependencies schema
additionalProperties: false
properties:
service-url:
type: string
description: URL of the service to send the actions to
)");
}
private:
const std::string service_url_;
};
class ActionDep {
public:
auto CreateActionRequest(std::string action) const { return component_.CreateHttpRequest(std::move(action)); }
static void RegisterOn(easy::HttpBase& app) {
app.
TryAddComponent<ActionClient>(ActionClient::kName,
"service-url: http://some-service.example/v1/action");
easy::HttpDep::RegisterOn(app);
}
private:
ActionClient& component_;
};
int main(int argc, char* argv[]) {
const auto& action = req.
GetArg(
"action");
deps.pg().Execute(
);
return deps.CreateActionRequest(action)->body();
});
}