Removed class ApiRouter.
This commit is contained in:
parent
1d78e7d60d
commit
ca7fb33848
7 changed files with 37 additions and 146 deletions
|
@ -48,6 +48,7 @@
|
|||
|
||||
#ifdef XMRIG_FEATURE_API
|
||||
# include "api/Api.h"
|
||||
# include "api/interfaces/IApiRequest.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -167,6 +168,7 @@ int xmrig::Base::init()
|
|||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
d_ptr->api = new Api(this);
|
||||
d_ptr->api->addListener(this);
|
||||
# endif
|
||||
|
||||
Platform::init(config()->userAgent());
|
||||
|
@ -288,3 +290,31 @@ void xmrig::Base::onFileChanged(const String &fileName)
|
|||
|
||||
d_ptr->replace(config);
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_API
|
||||
void xmrig::Base::onRequest(IApiRequest &request)
|
||||
{
|
||||
if (request.method() == IApiRequest::METHOD_GET) {
|
||||
if (request.url() == "/1/config") {
|
||||
if (request.isRestricted()) {
|
||||
return request.done(403);
|
||||
}
|
||||
|
||||
request.accept();
|
||||
config()->getJSON(request.doc());
|
||||
}
|
||||
}
|
||||
else if (request.method() == IApiRequest::METHOD_PUT || request.method() == IApiRequest::METHOD_POST) {
|
||||
if (request.url() == "/1/config") {
|
||||
request.accept();
|
||||
|
||||
if (!reload(request.json())) {
|
||||
return request.done(400);
|
||||
}
|
||||
|
||||
request.done(204);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define XMRIG_BASE_H
|
||||
|
||||
|
||||
#include "api/interfaces/IApiListener.h"
|
||||
#include "base/kernel/interfaces/IConfigListener.h"
|
||||
#include "base/kernel/interfaces/IWatcherListener.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
@ -35,13 +36,13 @@ namespace xmrig {
|
|||
|
||||
|
||||
class Api;
|
||||
class Config;
|
||||
class BasePrivate;
|
||||
class Config;
|
||||
class IBaseListener;
|
||||
class Process;
|
||||
|
||||
|
||||
class Base : public IWatcherListener
|
||||
class Base : public IWatcherListener, public IApiListener
|
||||
{
|
||||
public:
|
||||
Base(Process *process);
|
||||
|
@ -60,6 +61,10 @@ public:
|
|||
protected:
|
||||
void onFileChanged(const String &fileName) override;
|
||||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
void onRequest(IApiRequest &request) override;
|
||||
# endif
|
||||
|
||||
private:
|
||||
BasePrivate *d_ptr;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue