C and C++ web framework.
http://rapida.vilor.one/docs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
1.9 KiB
111 lines
1.9 KiB
/* SPDX-License-Identifier: GPL-3.0-or-later */ |
|
/* Copyright 2022 Ivan Polyakov */ |
|
|
|
#ifndef RAPIDA_REQUEST_HXX_ENTRY |
|
#define RAPIDA_REQUEST_HXX_ENTRY |
|
|
|
#include "Query.hxx" |
|
#include "request.h" |
|
|
|
namespace rpd { |
|
/*! |
|
* \brief C++ request wrapper. |
|
*/ |
|
class Request { |
|
public: |
|
/*! |
|
* \brief Constructor. |
|
* |
|
* Creates C++ wrapper from original C request. |
|
* |
|
* \param req C request implementation. |
|
*/ |
|
Request(rpd_req *req) |
|
{ |
|
this->req = req; |
|
} |
|
|
|
/*! |
|
* \brief Gets request method. |
|
* |
|
* \return Request method. |
|
*/ |
|
rpd_req_methods method() const |
|
{ |
|
return req->method; |
|
} |
|
|
|
/*! |
|
* \brief Gets requested URL. |
|
* |
|
* \return Request URL. |
|
*/ |
|
const rpd_url *path() const |
|
{ |
|
return &req->path; |
|
} |
|
|
|
/*! |
|
* \brief Gets query parameters. |
|
* |
|
* \return Query parameters. |
|
*/ |
|
Query query() const |
|
{ |
|
return &req->query; |
|
} |
|
|
|
/*! |
|
* \brief Gets URL parameters. |
|
* |
|
* If you specify route like <b>/some/:dynamic/route</b>, |
|
* middle route segment can be accesed by the _dynamic_ key. |
|
* |
|
* \return URL parameters as key-value pairs. |
|
*/ |
|
KeyVal params() const |
|
{ |
|
return &req->params; |
|
} |
|
|
|
/*! |
|
* \brief Gets authorization string. |
|
* |
|
* \return Authorization string. |
|
*/ |
|
const char *authorization() const |
|
{ |
|
return req->auth; |
|
} |
|
|
|
/*! |
|
* \brief Gets cookie string. |
|
* |
|
* \return Cookie string. |
|
*/ |
|
const char *cookie() const |
|
{ |
|
return req->cookie; |
|
}; |
|
|
|
/*! |
|
* \brief Gets request body content. |
|
* |
|
* \return Body content. |
|
*/ |
|
const char *body() const |
|
{ |
|
return req->body; |
|
} |
|
|
|
/*! |
|
* \brief Destructor. |
|
*/ |
|
virtual ~Request() { } |
|
|
|
private: |
|
rpd_req *req; //< Composition with C implementation. |
|
}; |
|
} |
|
|
|
#endif // RAPIDA_REQUEST_HXX_ENTRY
|
|
|