Instance
FossilOrigin-Name: 4f380a6968aa3b927ed99abc036548ebc1be6e671b6e8663ec489160bd5c6483
This commit is contained in:
parent
2fd5a283c5
commit
b30bc9530c
5 changed files with 62 additions and 27 deletions
|
@ -129,7 +129,6 @@ namespace
|
|||
// Call response, ensure that the request above is proprogated well!
|
||||
std::optional<HTTP::Response> resp = that->handle_request(req);
|
||||
|
||||
// TODO URGENT Slow to copy each time... Do alternative here.
|
||||
if (!resp)
|
||||
{
|
||||
// Return a 404
|
||||
|
@ -141,6 +140,7 @@ namespace
|
|||
MHD_destroy_response(response);
|
||||
return ret;
|
||||
}
|
||||
// TODO URGENT Slow to copy each time... Do alternative here.
|
||||
response = MHD_create_response_from_buffer(resp->data.size(),
|
||||
(void*)(resp->data.data()),
|
||||
MHD_RESPMEM_MUST_COPY);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include <yaml-cpp/null.h>
|
||||
#include "mastoapi.h"
|
||||
#include "instance/instance.h"
|
||||
#include "http/mime.h"
|
||||
|
@ -39,23 +38,26 @@ HTTP::Response Route::MastoAPI::create_app(std::any& args,
|
|||
rjson::Document root(rjson::kObjectType);
|
||||
rjson::Document::AllocatorType& a = root.GetAllocator();
|
||||
|
||||
// Required parameters
|
||||
try {
|
||||
const std::string& name = req.param.at("name").string();
|
||||
const std::string& redirect_uri = req.param.at("redirect_uri").string();
|
||||
const std::string& client_name =
|
||||
req.param.at("client_name").string();
|
||||
const std::string& redirect_uris =
|
||||
req.param.at("redirect_uris").string();
|
||||
|
||||
root.AddMember("name", name, a);
|
||||
root.AddMember("redirect_uri", redirect_uri, a);
|
||||
root.AddMember("name", client_name, a);
|
||||
root.AddMember("redirect_uri", redirect_uris, a);
|
||||
}
|
||||
catch (const std::out_of_range& err)
|
||||
{
|
||||
return HTTP::Error::make_json_error_response("Missing required parameters", HTTP::Code::BAD_REQUEST);
|
||||
}
|
||||
|
||||
// TODO scopes, bullshit aka for security freaks
|
||||
try {
|
||||
const std::string& website = req.param.at("website").string();
|
||||
root.AddMember("website", website, a);
|
||||
}
|
||||
catch(...) {
|
||||
} catch(...) {
|
||||
root.AddMember("website", rjson::Value(), a);
|
||||
}
|
||||
// Tokens
|
||||
|
@ -77,6 +79,6 @@ void Protocol::MastoAPI::init_masto_apps(HTTP::Server* server)
|
|||
{
|
||||
HTTP::Request::Type::POST,
|
||||
"/api/v1/apps",
|
||||
HTTP::MIME::Mimetypes::JSON
|
||||
HTTP::MIME::Mimetypes::ANY
|
||||
}, Route::MastoAPI::create_app});
|
||||
}
|
||||
|
|
|
@ -3,25 +3,16 @@
|
|||
* Licensed under BSD 3-Clause. See LICENSE
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef APPS_H
|
||||
#define APPS_H
|
||||
#include "http/httpserver.h"
|
||||
#include "http/response.h"
|
||||
|
||||
namespace Route
|
||||
{
|
||||
namespace MastoAPI
|
||||
{
|
||||
HTTP::Response create_app(std::any& args,
|
||||
HTTP::Request& req,
|
||||
const HTTP::RequestArgs_t& arg);
|
||||
}
|
||||
}
|
||||
HTTP::Response
|
||||
Route::MastoAPI::create_app(std::any& args,
|
||||
HTTP::Request& req,
|
||||
const HTTP::RequestArgs_t& arg);
|
||||
void
|
||||
Protocol::MastoAPI::init_masto_apps(HTTP::Server* server);
|
||||
|
||||
namespace Protocol
|
||||
{
|
||||
namespace MastoAPI
|
||||
{
|
||||
void init_masto_apps(HTTP::Server* server);
|
||||
}
|
||||
}
|
||||
#endif // APPS_H
|
||||
|
|
25
src/protocol/masto-api/instance.cpp
Normal file
25
src/protocol/masto-api/instance.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Wormhole - Federated social network
|
||||
* Licensed under BSD 3-Clause. See LICENSE
|
||||
*/
|
||||
|
||||
#include "instance.h"
|
||||
#include "route_args.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
HTTP::Response
|
||||
Route::MastoAPI::get_instance(std::any& args,
|
||||
HTTP::Request& req,
|
||||
HTTP::RequestArgs_t const& arg)
|
||||
{
|
||||
(void)args;
|
||||
(void)req;
|
||||
(void)arg;
|
||||
}
|
||||
|
||||
void
|
||||
Protocol::MastoAPI::init_instance_info(HTTP::Server* server)
|
||||
{
|
||||
|
||||
}
|
17
src/protocol/masto-api/instance.h
Normal file
17
src/protocol/masto-api/instance.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Wormhole - Federated social network
|
||||
* Licensed under BSD 3-Clause. See LICENSE
|
||||
*/
|
||||
|
||||
#ifndef INSTANCE_H
|
||||
#define INSTANCE_H
|
||||
#include "http/httpserver.h"
|
||||
|
||||
HTTP::Response
|
||||
Route::MastoAPI::create_instance(std::any& args,
|
||||
HTTP::Request& req,
|
||||
HTTP::RequestArgs_t const& arg);
|
||||
void
|
||||
Protocol::MastoAPI::init_instance_info(HTTP::Server* server);
|
||||
|
||||
#endif // INSTANCE_H
|
Loading…
Reference in a new issue