MythTV master
mythhttproot.cpp
Go to the documentation of this file.
1// MythTV
2#include "mythdirs.h"
3#include "http/mythhttproot.h"
4#include "http/mythhttpdata.h"
5#include "http/mythhttpfile.h"
8
9#define INDEX QStringLiteral("index.html")
10
25{
26 auto result = static_cast<HTTPResponse>(nullptr);
27 if (!Request)
28 return result;
29
30 // this is the top level handler. We deal with the empty root request
31 // and index.html
32 if (Request->m_fileName.isEmpty())
33 Request->m_fileName = INDEX;
34 if (Request->m_fileName != INDEX)
35 return result;
37
39 if (result)
40 return result;
41
42 if (!File.isEmpty())
43 {
44 Request->m_fileName = File;
46 // Rename the file
47 if (auto * file = std::get_if<HTTPFile>(&result->m_response))
48 (*file)->m_fileName = INDEX;
49 }
50 else
51 {
52 auto data = MythHTTPData::Create("index.html", s_defaultHTTPPage.arg("MythTV").toUtf8().constData());
54 }
55 return result;
56
57}
static HTTPData Create()
Definition: mythhttpdata.cpp:4
static HTTPResponse ProcessFile(const HTTPRequest2 &Request)
static HTTPResponse HandleOptions(const HTTPRequest2 &Request)
static HTTPResponse DataResponse(const HTTPRequest2 &Request, const HTTPData &Data)
static HTTPResponse RedirectRoot(const HTTPRequest2 &Request, const QString &File)
A convenience method to seemlessly redirect requests for index.html to a context specific file.
#define INDEX
Definition: mythhttproot.cpp:9
std::shared_ptr< MythHTTPRequest > HTTPRequest2
Definition: mythhttptypes.h:39
@ HTTPPut
Definition: mythhttptypes.h:96
@ HTTPDelete
Definition: mythhttptypes.h:97
std::shared_ptr< MythHTTPResponse > HTTPResponse
Definition: mythhttptypes.h:40
#define HTTP_DEFAULT_ALLOWED
static QString s_defaultHTTPPage