mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2024-12-27 21:35:41 +00:00
Hack to quickly get a new pastie's address when invoked from curl.
This commit is contained in:
parent
847988f4bd
commit
53b5a1a2af
2 changed files with 23 additions and 1 deletions
|
@ -155,7 +155,15 @@ namespace tawashi {
|
|||
statuslog->info("Pastie token=\"{}\" redirect=\"{}\"", *token, oss.str());
|
||||
if (not lang.empty())
|
||||
oss << '?' << lang;
|
||||
return this->make_redirect(HttpStatusCodes::Code303_SeeOther, oss.str());
|
||||
|
||||
//TODO: clean up this hack, make a separate class or something
|
||||
if (cgi_env().path_info().empty()) {
|
||||
m_redirect_to = oss.str();
|
||||
return HttpHeader();
|
||||
}
|
||||
else {
|
||||
return this->make_redirect(HttpStatusCodes::Code303_SeeOther, oss.str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
statuslog->info("Empty pastie token (possibly due to a previous failure)");
|
||||
|
@ -195,4 +203,12 @@ namespace tawashi {
|
|||
|
||||
return std::make_pair(boost::optional<std::string>(), make_error_redirect(ErrorReasons::PastieNotSaved));
|
||||
}
|
||||
|
||||
void SubmitPasteResponse::on_mustache_prepare (mstch::map& parContext) {
|
||||
parContext["redirect_to_address"] = m_redirect_to;
|
||||
}
|
||||
|
||||
std::string SubmitPasteResponse::on_mustache_retrieve() {
|
||||
return "{{base_uri}}/{{redirect_to_address}}\n";
|
||||
}
|
||||
} //namespace tawashi
|
||||
|
|
|
@ -39,6 +39,12 @@ namespace tawashi {
|
|||
private:
|
||||
typedef std::pair<boost::optional<std::string>, HttpHeader> StringOrHeader;
|
||||
virtual HttpHeader on_process() override;
|
||||
virtual void on_mustache_prepare (mstch::map& parContext) override;
|
||||
virtual std::string on_mustache_retrieve() override;
|
||||
StringOrHeader submit_to_redis (const boost::string_ref& parText, uint32_t parExpiry, const boost::string_ref& parLang);
|
||||
|
||||
//TODO: remove, this shouldn't be in this class, nor on_mustache_prepare
|
||||
//or on_mustache_retrieve.
|
||||
std::string m_redirect_to;
|
||||
};
|
||||
} //namespace tawashi
|
||||
|
|
Loading…
Reference in a new issue