|
5 | 5 |
|
6 | 6 | namespace msrv { |
7 | 7 |
|
8 | | -ClientConfigController::ClientConfigController(Request* request, SettingsDataPtr settings, const char* appName) |
9 | | - : ControllerBase(request), settings_(std::move(settings)), appName_(appName) |
| 8 | +ClientConfigController::ClientConfigController(Request* request, SettingsDataPtr settings) |
| 9 | + : ControllerBase(request), settings_(std::move(settings)) |
10 | 10 | { |
11 | 11 | } |
12 | 12 |
|
@@ -49,25 +49,19 @@ Path ClientConfigController::getFilePath() |
49 | 49 | auto id = param<std::string>("id"); |
50 | 50 |
|
51 | 51 | if (!std::regex_match(id, idPattern)) |
52 | | - { |
53 | 52 | throw InvalidRequestException("invalid configuration id: " + id); |
54 | | - } |
55 | 53 |
|
56 | | - auto configDir = SettingsData::getConfigDir(appName_); |
57 | | - if (configDir.empty()) |
58 | | - { |
59 | | - throw std::runtime_error("No config dir is available"); |
60 | | - } |
| 54 | + if (settings_->clientConfigDir.empty()) |
| 55 | + throw OperationForbiddenException(); |
61 | 56 |
|
62 | | - return configDir / MSRV_PATH_LITERAL("clientconfig") / pathFromUtf8(id + ".json"); |
| 57 | + return settings_->clientConfigDir / pathFromUtf8(id + ".json"); |
63 | 58 | } |
64 | 59 |
|
65 | | -void ClientConfigController::defineRoutes( |
66 | | - Router* router, WorkQueue* workQueue, SettingsDataPtr settings, const char* appName) |
| 60 | +void ClientConfigController::defineRoutes(Router* router, WorkQueue* workQueue, SettingsDataPtr settings) |
67 | 61 | { |
68 | 62 | auto routes = router->defineRoutes<ClientConfigController>(); |
69 | 63 |
|
70 | | - routes.createWith([=](Request* r) { return new ClientConfigController(r, settings, appName); }); |
| 64 | + routes.createWith([=](Request* r) { return new ClientConfigController(r, settings); }); |
71 | 65 | routes.useWorkQueue(workQueue); |
72 | 66 | routes.setPrefix("api/clientconfig"); |
73 | 67 |
|
|
0 commit comments