change the way how winix answer is created

Now we can return ezc content and models serialized in the same json structure,
Xml and Csv are not implemented yet.
Ezc frames are returned in 'ezc_frames' field.
Main ezc stream is returned in 'main_stream' field.
Frame url parameter can take more than one frame (names separated by commas).
Honor Accept http header (AcceptParser).

Samples:
--------
http://domain.tld/dir/controller
returns html answer from the main ezc stream

http://domain.tld/dir/controller/container:raw
returns html answer from the main ezc stream (the same as above)

http://domain.tld/dir/controller/frame:abc
returns "abc" frame as html

http://domain.tld/dir/controller/container:json
returns all serialized models to json and no ezc streams

http://domain.tld/dir/controller/container:xml
returns all serialized models to xml and no ezc streams (not implemented yet)

http://domain.tld/dir/controller/container:json/frame:abc,xyz
returns all serialized models to json and two frames in 'ezc_frames' object

http://domain.tld/dir/controller/container:json/all_frames
returns all serialized models to json and all frames in 'ezc_frames' object

http://domain.tld/dir/controller/container:json/main_stream
returns all serialized models and the main ezc stream in 'main_stream' field

http://domain.tld/dir/controller/container:json/main_stream/all_frames
returns all serialized models to json, all frames and the main stream
This commit is contained in:
2022-02-01 18:44:23 +01:00
parent 227dd923d6
commit f7b5ac0dc8
17 changed files with 695 additions and 395 deletions

View File

@@ -54,6 +54,7 @@
#include "cookieparser.h"
#include "postmultiparser.h"
#include "acceptencodingparser.h"
#include "acceptparser.h"
#include "winixrequest.h"
#include "log/log.h"
#include "filelog.h"
@@ -140,6 +141,7 @@ private:
CookieParser cookie_parser;
AcceptEncodingParser accept_encoding_parser;
AcceptParser accept_parser;
Compress compress;
FCGX_Request fcgi_request;
int fcgi_socket;
@@ -199,7 +201,7 @@ private:
void CheckIfNeedSSLredirect();
void SetLocale();
void CheckPostRedirect();
void MakeEzcGenerator();
void UseEzcGenerator();
void AddDefaultModels();
void Make();
void SaveSessionsIfNeeded(); // !! IMPROVE ME wywalic do menagera sesji??
@@ -207,14 +209,24 @@ private:
void SendData(const BinaryPage & page, FCGX_Stream * out);
void ReadRequest();
void SendAnswer();
void PrepareRawAnswer();
void PrepareJsonAnswer();
void PrepareXmlAnswer();
void PrepareCsvAnswer();
void PrepareContenerizedAnswer();
void PutSeparatorIfNeeded(bool put_separator);
void SerializeFieldJson(const wchar_t * field_name);
void SerializeStream(const pt::WTextStream & input_stream, const wchar_t * field_name);
void SerializeStreamJson(const pt::WTextStream & input_stream, const wchar_t * field_name);
void SerializeStreamXml(const pt::WTextStream & input_stream, const wchar_t * field_name);
void SerializeStreamCsv(const pt::WTextStream & input_stream, const wchar_t * field_name);
void SerializeFrames();
void SerializeAllFrames();
void SerializeOneFrame();
void SerializeSpecificFrames();
void SerializeModels();
void Send8bitOutput(BinaryPage & output);