22 return absl::AlreadyExistsError(
"Server is already running");
26 return absl::InternalError(
"HttpServer is not valid");
34 LOG_INFO(
"HttpServer",
"Starting API server on port %d",
port);
46 LOG_INFO(
"HttpServer",
"Bonjour discovery published on port %d",
port);
48 LOG_ERROR(
"HttpServer",
"Bonjour discovery failed to publish on port %d",
53 "Bonjour discovery not available on this platform, skipping");
56 return absl::OkStatus();
61 LOG_INFO(
"HttpServer",
"Stopping API server...");
68 LOG_INFO(
"HttpServer",
"API server stopped");
78 [](
const httplib::Request& req, httplib::Response& res) {
81 if (!res.body.empty()) {
84 const char* message =
"Request failed";
87 message =
"Bad request";
90 message =
"Not found";
93 message =
"Method not allowed";
96 message =
"Not implemented";
99 message =
"Service unavailable";
102 message =
"Internal server error";
107 std::string body = std::string(
"{\"error\":\"") + message +
"\"}";
108 res.set_content(body,
"application/json");
112 [
this](
const httplib::Request& req, httplib::Response& res) {
119 server_->Get(
"/api/v1/symbols",
120 [
this](
const httplib::Request& req, httplib::Response& res) {
136 server_->Post(
"/api/v1/window/show",
137 [
this](
const httplib::Request& req, httplib::Response& res) {
142 server_->Post(
"/api/v1/window/hide",
143 [
this](
const httplib::Request& req, httplib::Response& res) {
148 server_->Get(
"/api/v1/render/dungeon",
149 [
this](
const httplib::Request& req, httplib::Response& res) {
156 server_->Get(
"/api/v1/render/dungeon/metadata",
157 [
this](
const httplib::Request& req, httplib::Response& res) {
165 server_->Post(
"/api/v1/command/execute",
166 [
this](
const httplib::Request& req, httplib::Response& res) {
175 auto project_path_lambda = [
this]() -> std::string {
178 server_->Get(
"/api/v1/annotations",
179 [project_path_lambda](
const httplib::Request& req,
180 httplib::Response& res) {
183 server_->Post(
"/api/v1/annotations",
184 [project_path_lambda](
const httplib::Request& req,
185 httplib::Response& res) {
188 server_->Put(R
"(/api/v1/annotations/(.+))",
189 [project_path_lambda](const httplib::Request& req,
190 httplib::Response& res) {
193 server_->Delete(R
"(/api/v1/annotations/(.+))",
194 [project_path_lambda](const httplib::Request& req,
195 httplib::Response& res) {
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
void Unpublish()
Stop advertising. Safe to call multiple times.
void Publish(int port, const std::string &rom_title="")
Start advertising. Call after the HTTP server socket is bound.
std::unique_ptr< httplib::Server > server_
BonjourPublisher bonjour_
RenderServiceSource render_source_
WindowAction window_show_
SymbolProviderSource symbol_source_
WindowAction window_hide_
absl::Status Start(int port)
ProjectPathSource project_path_source_
std::unique_ptr< std::thread > server_thread_
std::atomic< bool > is_running_
Provider for symbol (label) resolution in disassembly.
#define LOG_ERROR(category, format,...)
#define LOG_INFO(category, format,...)
void HandleStateUpdate(const httplib::Request &req, httplib::Response &res)
void ApplyCorsHeaders(httplib::Response &res)
void HandleCorsPreflight(const httplib::Request &req, httplib::Response &res)
void HandleBreakpointHit(const httplib::Request &req, httplib::Response &res)
void HandleListModels(const httplib::Request &req, httplib::Response &res)
void HandleGetSymbols(const httplib::Request &req, httplib::Response &res, yaze::emu::debug::SymbolProvider *symbols)
void HandleNavigate(const httplib::Request &req, httplib::Response &res)
void HandleWindowShow(const httplib::Request &req, httplib::Response &res, const std::function< bool()> &action)
void HandleAnnotationUpdate(const httplib::Request &req, httplib::Response &res, const std::string &project_path)
void HandleRenderDungeonMetadata(const httplib::Request &req, httplib::Response &res, yaze::app::service::RenderService *render_service)
void HandleRenderDungeon(const httplib::Request &req, httplib::Response &res, yaze::app::service::RenderService *render_service)
void HandleCommandExecute(const httplib::Request &req, httplib::Response &res, yaze::Rom *rom)
void HandleAnnotationDelete(const httplib::Request &req, httplib::Response &res, const std::string &project_path)
void HandleAnnotationList(const httplib::Request &req, httplib::Response &res, const std::string &project_path)
void HandleAnnotationCreate(const httplib::Request &req, httplib::Response &res, const std::string &project_path)
void HandleCommandList(const httplib::Request &req, httplib::Response &res)
void HandleWindowHide(const httplib::Request &req, httplib::Response &res, const std::function< bool()> &action)
void HandleHealth(const httplib::Request &req, httplib::Response &res, const BonjourPublisher *bonjour)