VWeb/Includes/Request.h

34 lines
1 KiB
C
Raw Normal View History

#pragma once
#include "Cookie.h"
#include "Http.h"
#include "ParameterValue.h"
#include "Session.h"
#include <string>
#include <vector>
namespace VWeb {
struct Request {
public:
int ID;
std::string Body;
HttpMethod Method{HttpMethod::GET};
std::string URI;
Ref<Session> SessionData;
Ref<Cookies> CookieData;
Cookie &GetCookie(const std::string &key) { return CookieData->Get(key); };
ParameterValue &Parameter(const std::string &key) { return Parameters[key]; }
bool HasParameter(const std::string &key) const {
return Parameters.contains(key);
}
bool HasHeader(const std::string &key) const { return Headers.contains(key); }
std::string &FirstOf(const std::string &key) {
return Parameters[key].GetFirst();
}
ParameterValue &Header(const std::string &key) { return Headers[key]; }
std::unordered_map<std::string, ParameterValue> Parameters;
std::unordered_map<std::string, ParameterValue> Headers;
std::unordered_map<std::string, std::string> URLParameters;
};
} // namespace VWeb