5#include "actionrest_p.h"
15using namespace Qt::StringLiterals;
56 :
Action(new ActionRESTPrivate(this), parent)
64 int &actionRefCount = c->d_ptr->actionRefCount;
74 c->d_ptr->pendingAsync.enqueue(action);
84ActionRESTPrivate::ActionRESTPrivate(
ActionREST *q)
99 for (
Action *controllerAction : actions) {
100 if (controllerAction->name() == restMethod) {
101 action = controllerAction;
108 if (httpMethod ==
"HEAD") {
110 action = getRestAction(c,
"GET"_ba);
111 }
else if (httpMethod ==
"OPTIONS") {
112 returnOptions(c, q->name());
113 }
else if (httpMethod ==
"not_implemented") {
115 returnNotImplemented(c, q->name());
118 action = getRestAction(c,
"not_implemented"_ba);
125void ActionRESTPrivate::returnOptions(
Context *c,
const QString &methodName)
const
134void ActionRESTPrivate::returnNotImplemented(
Context *c,
const QString &methodName)
const
137 response->
setStatus(Response::MethodNotAllowed);
140 const QByteArray body =
"Method " + c->
req()->method() +
" not implemented for " +
146 const QString &methodName)
const
149 const QString name = methodName + u
'_';
151 for (
Action *action : actions) {
159 methods.
append(QStringLiteral(
"HEAD"));
169#include "moc_actionrest.cpp"
Automated REST method dispatching.
bool doExecute(Context *c) override
ActionREST(QObject *parent=nullptr)
This class represents a Cutelyst Action.
bool doExecute(Context *c) override
QString name() const noexcept
bool execute(Component *code)
Response * response() const noexcept
Cutelyst Controller base class.
ActionList actions() const noexcept
Action * actionFor(QStringView name) const
void setContentType(const QByteArray &type)
void setStatus(quint16 status) noexcept
void setHeader(const QByteArray &key, const QByteArray &value)
void setBody(QIODevice *body)
The Cutelyst namespace holds all public Cutelyst API.
void append(QList::parameter_type value)
bool removeOne(const AT &t)
QString fromLatin1(QByteArrayView str)
QString mid(qsizetype position, qsizetype n) const const
qsizetype size() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QByteArray toLatin1() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
QString join(QChar separator) const const
qsizetype removeDuplicates()
void sort(Qt::CaseSensitivity cs)
QString toString(QUrl::FormattingOptions options) const const