MastoAPI basis
FossilOrigin-Name: de98195715bc63613a8f0b6e92deb67286d8c7ee0d010cbca074d18dda2fdef5
This commit is contained in:
parent
8f2184983b
commit
20ffe19a2b
6 changed files with 105 additions and 0 deletions
|
@ -39,6 +39,7 @@ add_module(HOST_META)
|
|||
add_module(WEBFINGER)
|
||||
add_module(ACTIVITYPUB)
|
||||
add_module(OAUTH)
|
||||
add_module(MASTO_API)
|
||||
|
||||
# General includes
|
||||
include(CTest)
|
||||
|
@ -109,6 +110,7 @@ target_link_libraries(wormhole wormhole_lib
|
|||
wormhole_activitypub_module
|
||||
wormhole_host_meta_module
|
||||
wormhole_oauth_module
|
||||
wormhole_masto_api_module
|
||||
${CMAKE_DL_LIBS}
|
||||
${LIBMICROHTTPD_LIBRARIES}
|
||||
${SQLite3_LIBRARIES}
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
#ifdef MODULE_OAUTH
|
||||
#include "protocol/oauth/oauth.h"
|
||||
#endif // MODULE_OAUTH
|
||||
#ifdef MODULE_MASTO_API
|
||||
#include "protocol/masto-api/mastoapi.h"
|
||||
#endif // MODULE_MASTO_API
|
||||
|
||||
void init_routes(const std::unique_ptr<HTTP::Server>& server)
|
||||
{
|
||||
|
@ -61,6 +64,9 @@ void init_routes(const std::unique_ptr<HTTP::Server>& server)
|
|||
#ifdef MODULE_OAUTH
|
||||
Protocol::OAuth::init_oauth(server.get());
|
||||
#endif // MODULE_OAUTH
|
||||
#ifdef MODULE_MASTO_API
|
||||
Protocol::MastoAPI::init_masto_api(server.get());
|
||||
#endif // MODULE_MASTO_API
|
||||
}
|
||||
|
||||
int start_wormhole()
|
||||
|
|
|
@ -13,3 +13,7 @@ endif()
|
|||
if (MODULE_OAUTH)
|
||||
add_subdirectory(oauth)
|
||||
endif()
|
||||
|
||||
if (MODULE_MASTO_API)
|
||||
add_subdirectory(masto-api)
|
||||
endif()
|
||||
|
|
4
src/protocol/masto-api/CMakeLists.txt
Normal file
4
src/protocol/masto-api/CMakeLists.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
add_library(wormhole_masto_api_module
|
||||
mastoapi.cpp)
|
||||
include_directories(wormhole_masto_api_module ${WORMHOLE_INCLUDE_DIRS})
|
||||
target_link_libraries(wormhole_masto_api_module wormhole_lib)
|
52
src/protocol/masto-api/mastoapi.cpp
Normal file
52
src/protocol/masto-api/mastoapi.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Wormhole - Federated social network
|
||||
* Copyright (C) 2022 Nekobit
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include "mastoapi.h"
|
||||
#include "instance/instance.h"
|
||||
#include "http/mime.h"
|
||||
#include "http/response.h"
|
||||
#include "http/responsecode.h"
|
||||
#include "http/httpserver.h"
|
||||
#include "http/error_response.h"
|
||||
#include "http/request.h"
|
||||
#include "user.h"
|
||||
#include "logger.h"
|
||||
#include "jsonhelper.h"
|
||||
#include "route_args.h"
|
||||
|
||||
using namespace Protocol;
|
||||
|
||||
|
||||
HTTP::Response Route::masto_api(std::any& args,
|
||||
const HTTP::Request& req,
|
||||
const HTTP::RequestArgs_t& arg)
|
||||
{
|
||||
using namespace std::string_literals;
|
||||
|
||||
//DESTRUCT_WORMHOLE_ARGS(args);
|
||||
|
||||
return HTTP::Response{ "{}", HTTP::MIME::JSON };
|
||||
}
|
||||
|
||||
void MastoAPI::init_masto_api(HTTP::Server* server)
|
||||
{
|
||||
server->add_route({{HTTP::Request::Type::GET, "/api/v1/"}, Route::masto_api});
|
||||
}
|
37
src/protocol/masto-api/mastoapi.h
Normal file
37
src/protocol/masto-api/mastoapi.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Wormhole - Federated social network
|
||||
* Copyright (C) 2022 Nekobit
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "http/httpserver.h"
|
||||
#include "http/response.h"
|
||||
|
||||
namespace Route
|
||||
{
|
||||
HTTP::Response masto_api(std::any& args,
|
||||
const HTTP::Request& req,
|
||||
const HTTP::RequestArgs_t& arg);
|
||||
}
|
||||
|
||||
namespace Protocol
|
||||
{
|
||||
namespace MastoAPI
|
||||
{
|
||||
void init_masto_api(HTTP::Server* server);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue