Skip to content

Commit

Permalink
Change /showtime/ in HTTP server to /api/
Browse files Browse the repository at this point in the history
  • Loading branch information
andoma committed Nov 25, 2015
1 parent e4784ed commit 0bc7baf
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Expand Up @@ -82,5 +82,5 @@ $ ./Autobuild.sh -t rpi

To update Movian on rpi with compiled one, enable Binreplace in settings:dev and issue:

curl --data-binary @build.rpi/showtime.sqfs http://rpi_ip_address:42000/showtime/replace
curl --data-binary @build.rpi/showtime.sqfs http://rpi_ip_address:42000/api/replace

32 changes: 16 additions & 16 deletions src/api/httpcontrol.c
Expand Up @@ -56,7 +56,7 @@ hc_open(http_connection_t *hc, const char *remain, void *opaque,

if(url != NULL) {
event_to_ui(event_create_openurl(url));
return http_redirect(hc, "/showtime/open");
return http_redirect(hc, "/api/open");
}

htsbuf_queue_init(&out, 0);
Expand Down Expand Up @@ -93,7 +93,7 @@ diag_html(http_connection_t *hc, htsbuf_queue_t *out)


htsbuf_qprintf(out,
APPNAME"-%d.log (Last modified %s ago): <a href=\"/showtime/logfile/%d\">View</a> | <a href=\"/showtime/logfile/%d?mode=download\">Download</a>| <a href=\"/showtime/logfile/%d?mode=pastebin\">Pastebin</a><br>", i, timestr, i, i, i);
APPNAME"-%d.log (Last modified %s ago): <a href=\"/api/logfile/%d\">View</a> | <a href=\"/api/logfile/%d?mode=download\">Download</a>| <a href=\"/api/logfile/%d?mode=pastebin\">Pastebin</a><br>", i, timestr, i, i, i);
}
}

Expand Down Expand Up @@ -130,8 +130,8 @@ hc_root_old(http_connection_t *hc)
htsbuf_qprintf(&out, "<h3>Diagnostics</h3>");

diag_html(hc, &out);
htsbuf_qprintf(&out, "<p><a href=\"/showtime/screenshot\">Upload screenshot to imgur</a></p>");
htsbuf_qprintf(&out, "<p><a href=\"/showtime/translation\">Upload and test new translation (.lang) file</a></p>");
htsbuf_qprintf(&out, "<p><a href=\"/api/screenshot\">Upload screenshot to imgur</a></p>");
htsbuf_qprintf(&out, "<p><a href=\"/api/translation\">Upload and test new translation (.lang) file</a></p>");

htsbuf_qprintf(&out, "</body></html>");

Expand Down Expand Up @@ -665,22 +665,22 @@ hc_open_parameterized(http_connection_t *hc, const char *remain,
static void
httpcontrol_init(void)
{
http_path_add("/showtime/done", NULL, hc_done, 0);
http_path_add("/showtime/image", NULL, hc_image, 0);
http_path_add("/showtime/open", NULL, hc_open, 1);
http_path_add("/showtime/openparameterized", NULL, hc_open_parameterized, 0);
http_path_add("/showtime/input/action", NULL, hc_action, 0);
http_path_add("/showtime/input/utf8", NULL, hc_utf8, 1);
http_path_add("/showtime/notifyuser", NULL, hc_notify_user, 1);
http_path_add("/showtime/diag", NULL, hc_diagnostics, 1);
http_path_add("/showtime/logfile", NULL, hc_logfile, 0);
http_path_add("/showtime/replace", NULL, hc_binreplace, 1);
http_add_websocket("/showtime/ws/echo",
http_path_add("/api/done", NULL, hc_done, 0);
http_path_add("/api/image", NULL, hc_image, 0);
http_path_add("/api/open", NULL, hc_open, 1);
http_path_add("/api/openparameterized", NULL, hc_open_parameterized, 0);
http_path_add("/api/input/action", NULL, hc_action, 0);
http_path_add("/api/input/utf8", NULL, hc_utf8, 1);
http_path_add("/api/notifyuser", NULL, hc_notify_user, 1);
http_path_add("/api/diag", NULL, hc_diagnostics, 1);
http_path_add("/api/logfile", NULL, hc_logfile, 0);
http_path_add("/api/replace", NULL, hc_binreplace, 1);
http_add_websocket("/api/ws/echo",
hc_echo_init, hc_echo_data, hc_echo_fini);

http_path_add("/", NULL, hc_root, 1);
http_path_add("/favicon.ico", NULL, hc_favicon, 1);
http_path_add("/showtime/static", NULL, hc_static, 0);
http_path_add("/api/static", NULL, hc_static, 0);
}

INITME(INIT_GROUP_API, httpcontrol_init, NULL);
2 changes: 1 addition & 1 deletion src/api/screenshot.c
Expand Up @@ -288,7 +288,7 @@ static void
screenshot_init(void)
{
hts_mutex_init(&screenshot_mutex);
http_path_add("/showtime/screenshot", NULL, hc_screenshot, 0);
http_path_add("/api/screenshot", NULL, hc_screenshot, 0);
}

INITME(INIT_GROUP_API, screenshot_init, NULL);
2 changes: 1 addition & 1 deletion src/api/stpp.c
Expand Up @@ -994,7 +994,7 @@ stpp_fini(http_connection_t *hc, void *opaque)
static void
ws_init(void)
{
http_add_websocket("/showtime/stpp", stpp_init, stpp_input, stpp_fini);
http_add_websocket("/api/stpp", stpp_init, stpp_input, stpp_fini);
}


Expand Down
3 changes: 3 additions & 0 deletions src/arch/ps3/ps3.mk
Expand Up @@ -98,4 +98,7 @@ $(BUILDDIR)/dist/${APPNAME}_geohot-$(VERSION).pkg: $(BUILDDIR)/${APPNAME}_geohot
dist: $(BUILDDIR)/dist/${APPNAME}-$(VERSION).self $(BUILDDIR)/dist/${APPNAME}-$(VERSION).pkg $(BUILDDIR)/dist/${APPNAME}_geohot-$(VERSION).pkg

upgrade: ${SELF}
curl --data-binary @$< http://$(PS3HOST):42000/api/replace

upgrade-old: ${SELF}
curl --data-binary @$< http://$(PS3HOST):42000/showtime/replace
2 changes: 1 addition & 1 deletion src/arch/ps3/ps3_tlsf.c
Expand Up @@ -67,7 +67,7 @@ static void __attribute__((constructor)) mallocsetup(void)

// Malloc is initialized now so we can safely do this

http_path_add("/showtime/memstats", NULL, memstats, 1);
http_path_add("/api/memstats", NULL, memstats, 1);
}

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bittorrent/torrent_stats.c
Expand Up @@ -196,7 +196,7 @@ torrent_dump_http(http_connection_t *hc, const char *remain, void *opaque,
static void
torrent_stats_init(void)
{
http_path_add("/showtime/torrents", NULL, torrent_dump_http, 1);
http_path_add("/api/torrents", NULL, torrent_dump_http, 1);
}

INITME(INIT_GROUP_API, torrent_stats_init, NULL);
2 changes: 1 addition & 1 deletion src/ecmascript/es_stats.c
Expand Up @@ -104,7 +104,7 @@ dumpstats(http_connection_t *hc, const char *remain, void *opaque,
static void
ecmascript_stats_init(void)
{
http_path_add("/showtime/ecmascript/stats", NULL, dumpstats, 1);
http_path_add("/api/ecmascript/stats", NULL, dumpstats, 1);
}

INITME(INIT_GROUP_API, ecmascript_stats_init, NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/i18n.c
Expand Up @@ -810,7 +810,7 @@ nls_init(prop_t *parent, htsmsg_t *store)
lang_t *l;

#if ENABLE_HTTPSERVER
http_path_add("/showtime/translation", NULL, upload_translation, 1);
http_path_add("/api/translation", NULL, upload_translation, 1);
#endif

if(fd == NULL) {
Expand Down
15 changes: 10 additions & 5 deletions src/networking/http_server.c
Expand Up @@ -202,20 +202,25 @@ static const http_path_t *
http_resolve(http_connection_t *hc, char **remainp, char **argsp)
{
http_path_t *hp;
char *v;
char *url = hc->hc_url;
if(!strncmp(url, "/showtime/", strlen("/showtime/"))) {
url += 5;
memcpy(url, "/api", 4);
}

LIST_FOREACH(hp, &http_paths, hp_link) {
if(!strncmp(hc->hc_url, hp->hp_path, hp->hp_len)) {
if(hc->hc_url[hp->hp_len] == 0 || hc->hc_url[hp->hp_len] == '/' ||
hc->hc_url[hp->hp_len] == '?')
if(!strncmp(url, hp->hp_path, hp->hp_len)) {
if(url[hp->hp_len] == 0 ||
url[hp->hp_len] == '/' ||
url[hp->hp_len] == '?')
break;
}
}

if(hp == NULL)
return NULL;

v = hc->hc_url + hp->hp_len;
char *v = url + hp->hp_len;

*remainp = NULL;
*argsp = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/prop/prop_http.c
Expand Up @@ -181,7 +181,7 @@ hc_prop(http_connection_t *hc, const char *remain, void *opaque,

htsbuf_qprintf(&out, "<tr>\n");

htsbuf_qprintf(&out, "<td><a href=\"/showtime/prop/%s/%s\">",
htsbuf_qprintf(&out, "<td><a href=\"/api/prop/%s/%s\">",
remain, ref);
htsbuf_append_and_escape_xml(&out, cname);
htsbuf_qprintf(&out, "</a>\n");
Expand Down Expand Up @@ -271,7 +271,7 @@ hc_subtrack(http_connection_t *hc, const char *remain, void *opaque,
static void
prop_http_init(void)
{
http_path_add("/showtime/prop", NULL, hc_prop, 0);
http_path_add("/api/prop", NULL, hc_prop, 0);
#ifdef PROP_DEBUG
http_path_add("/subtrack", NULL, hc_subtrack, 0);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/prop/prop_proxy.c
Expand Up @@ -131,7 +131,7 @@ ppc_connected(void *aux, const char *err)
}

snprintf(buf, sizeof(buf),
"GET /showtime/stpp HTTP/1.1\r\n"
"GET /api/stpp HTTP/1.1\r\n"
"Connection: Upgrade\r\n"
"Upgrade: websocket\r\n"
"Sec-WebSocket-Key: 1\r\n"
Expand Down
2 changes: 1 addition & 1 deletion src/upnp/upnp_avtransport.c
Expand Up @@ -308,7 +308,7 @@ build_didl(const char *myhost, int myport)
const char *arturl;

if(strncmp(upnp_current_album_art, "http://", strlen("http://"))) {
snprintf(url, sizeof(url), "http://%s:%d/showtime/image/%s",
snprintf(url, sizeof(url), "http://%s:%d/api/image/%s",
myhost, myport, upnp_current_album_art);
arturl = url;
} else {
Expand Down

0 comments on commit 0bc7baf

Please sign in to comment.