SaltAPI  1.1
An API for the HTTPd / Zia by Salty Studio.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AddEvent.cpp
Go to the documentation of this file.
1 //
2 // Created by wery_a on 09/01/17.
3 //
4 
5 #include <functional>
6 #include "AddEvent.hpp"
7 #include "HTTP/Request.hpp"
8 #include "HTTP/Response.hpp"
10 #include "Module/ACore.hpp"
11 #include "Compress.hpp"
12 
13 AddEvent::AddEvent(Module::ICore &core): Module::AModule(core, HTTP, "AddEvent") {
14 
15 }
16 
18 
19 }
20 
22  Compress *compressModule = dynamic_cast<Compress*>(m_core.Get("Compress"));
23 
24  pl->pushAfter(std::bind(&Compress::UnZip, compressModule, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3),
25  pl->begin());
26  pl->pushBefore(std::bind(&Compress::Zip, compressModule, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), pl->end());
27 
28  res->GetHeader().Add("Content-Type", "text/plain");
29  res->SetBody("AddEvent");
30  res->SetStatusCode(200);
31  return true;
32 }
33 
35  return new AddEvent(core);
36 }
EventFunctionList::iterator begin()
bool pushBefore(EventFunction eventFunction, EventFunctionList::const_iterator ref)
push eventFunction before iterator
void SetStatusCode(unsigned int code)
set code
Definition: Response.cpp:32
ICore & m_core
Definition: AModule.hpp:20
virtual ~AddEvent()
Definition: AddEvent.cpp:17
virtual IModule * Get(std::string const &name) const =0
Get the module by name from the list in ModuleLoader.
Module::IModule * GetModule(Module::ICore &core) const override
The function return an instance of the module.
Definition: AddEvent.cpp:34
bool UnZip(HTTP::Request *req, HTTP::Response *res, HTTP::ProcessingList *pl)
Definition: Compress.cpp:22
Header & GetHeader()
Definition: Message.cpp:18
EventFunctionList::iterator end()
bool Zip(HTTP::Request *req, HTTP::Response *res, HTTP::ProcessingList *pl)
Definition: Compress.cpp:18
bool pushAfter(EventFunction eventFunction, EventFunctionList::const_iterator ref)
push eventFunction after iterator
void Add(std::string const &key, std::string const &value)
Definition: Header.cpp:28
AddEvent(Module::ICore &core)
Definition: AddEvent.cpp:13
bool Handle(HTTP::Request *req, HTTP::Response *res, HTTP::ProcessingList *pl)
Definition: AddEvent.cpp:21
void SetBody(std::string const &body)
set body
Definition: Message.cpp:38