5 #include "actionrest_p.h" 8 #include "controller.h" 9 #include "dispatcher.h" 56 :
Action(new ActionRESTPrivate(this), parent)
64 const int &actionRefCount = c->d_ptr->actionRefCount;
74 c->d_ptr->pendingAsync.enqueue(action);
84 ActionRESTPrivate::ActionRESTPrivate(
ActionREST *q)
94 const Controller *controller = q->controller();
99 auto it = std::ranges::find_if(actions, [&restMethod](
const Action *controllerAction) {
100 return controllerAction->
name() == restMethod;
102 if (it != actions.
end()) {
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);
125 void ActionRESTPrivate::returnOptions(
Context *c,
const QString &methodName)
const 134 void 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 (
const Action *action : actions) {
159 methods.
append(u
"HEAD"_s);
169 #include "moc_actionrest.cpp"
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
bool doExecute(Context *c) override
qsizetype removeDuplicates()
qsizetype size() const const
QString join(QChar separator) const const
QString toString(FormattingOptions options) const const
void setContentType(const QByteArray &type)
This class represents a Cutelyst Action.
Cutelyst Controller base class.
Automated REST method dispatching.
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
bool doExecute(Context *c) override
QString name() const noexcept
The Cutelyst namespace holds all public Cutelyst API.
bool execute(Component *code)
ActionREST(QObject *parent=nullptr)
QString fromLatin1(QByteArrayView str)
QByteArray toLatin1() const const
QString mid(qsizetype position, qsizetype n) const const
void append(QList< T > &&value)
void sort(Qt::CaseSensitivity cs)
Action * actionFor(QStringView name) const
void setBody(QIODevice *body)
Response * response() const noexcept
void setStatus(quint16 status) noexcept
bool removeOne(const AT &t)
ActionList actions() const noexcept
void setHeader(const QByteArray &key, const QByteArray &value)