convert modules to new paths

This commit is contained in:
bitful-pannul 2023-10-20 00:11:25 +02:00
parent 63e3ec4379
commit 411a2d3dc8
4 changed files with 23 additions and 23 deletions

View File

@ -190,7 +190,7 @@ impl Guest for Component {
expects_response: None,
ipc: Some(json!({
"BindPath": {
"path": "/chess",
"path": "/",
"authenticated": true,
"local_only": false
}
@ -207,7 +207,7 @@ impl Guest for Component {
expects_response: None,
ipc: Some(json!({
"BindPath": {
"path": "/chess/games",
"path": "/games",
"authenticated": true,
"local_only": false
}
@ -483,7 +483,7 @@ impl Guest for Component {
default_headers.insert("Content-Type".to_string(), "text/html".to_string());
// Handle incoming http
match path {
"/chess" => {
"/" => {
send_http_response(
200,
default_headers.clone(),
@ -497,7 +497,7 @@ impl Guest for Component {
.to_vec(),
);
}
"/chess/games" => {
"/games" => {
match method {
"GET" => {
send_http_response(

View File

@ -196,8 +196,8 @@
<h4>Apps:</h4>
<!-- <a id="file-transfer" href="/file-transfer">File Transfer</a> -->
<a id="chess" href="/chess">Chess</a>
<a id="http-proxy" href="/http-proxy">HTTP Proxy</a>
<a id="chess" href="/chess:chess:uqbar/">Chess</a>
<a id="http-proxy" href="/http_proxy:http_proxy:uqbar/">HTTP Proxy</a>
</div>
<script>window.ourName = window.our = '${our}'</script>
<script>

View File

@ -231,14 +231,14 @@
</div>
<script>
function genFetchRoute(route) {
return window.location.pathname.includes('/http-proxy/serve/') ?
`/http-proxy/serve/${window.location.pathname.split('/')[3]}/${route}`:
return window.location.pathname.includes('/http_proxy:http_proxy:uqbar/serve/') ?
`/http_proxy:http_proxy:uqbar/serve/${window.location.pathname.split('/')[3]}/${route}`:
route
}
async function getProxies() {
try {
const result = await fetch(genFetchRoute(`/http-proxy/list`)).then(r => r.json()).catch(() => null)
const result = await fetch(genFetchRoute(`/http_proxy:http_proxy:uqbar/list`)).then(r => r.json()).catch(() => null)
if (!result || !result.registrations) return
const proxyList = document.getElementById('proxy-list')
@ -273,7 +273,7 @@
try {
const username = document.querySelector('input[name="username"]').value
document.querySelector('input[name="username"]').value = ''
await fetch(genFetchRoute(`/http-proxy/register`), {
await fetch(genFetchRoute(`/http_proxy:http_proxy:uqbar/register`), {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@ -288,7 +288,7 @@
async function removeProxy(username) {
try {
await fetch(genFetchRoute(`/http-proxy/register?username=${username}`), {
await fetch(genFetchRoute(`/http_proxy:http_proxy:uqbar/register?username=${username}`), {
method: 'DELETE',
})
getProxies()

View File

@ -66,7 +66,7 @@ impl Guest for Component {
expects_response: None,
ipc: Some(json!({
"BindPath": {
"path": "/http-proxy",
"path": "/",
"authenticated": true,
"local_only": false
}
@ -83,7 +83,7 @@ impl Guest for Component {
expects_response: None,
ipc: Some(json!({
"BindPath": {
"path": "/http-proxy/static/*",
"path": "/static/*",
"authenticated": true,
"local_only": false
}
@ -100,7 +100,7 @@ impl Guest for Component {
expects_response: None,
ipc: Some(json!({
"BindPath": {
"path": "/http-proxy/list",
"path": "/list",
"authenticated": true,
"local_only": false
}
@ -117,7 +117,7 @@ impl Guest for Component {
expects_response: None,
ipc: Some(json!({
"BindPath": {
"path": "/http-proxy/register",
"path": "/register",
"authenticated": true,
"local_only": false
}
@ -134,7 +134,7 @@ impl Guest for Component {
expects_response: None,
ipc: Some(json!({
"BindPath": {
"path": "/http-proxy/serve/:username/*",
"path": "/serve/:username/*",
"authenticated": true,
"local_only": false
}
@ -178,7 +178,7 @@ impl Guest for Component {
format!("http_proxy: got request: {}", message_json).as_str(),
);
if message_json["path"] == "/http-proxy" && message_json["method"] == "GET" {
if message_json["path"] == "/" && message_json["method"] == "GET" {
send_response(
&Response {
inherit: false,
@ -202,7 +202,7 @@ impl Guest for Component {
.to_vec(),
}),
);
} else if message_json["path"] == "/http-proxy/list" && message_json["method"] == "GET"
} else if message_json["path"] == "/list" && message_json["method"] == "GET"
{
send_response(
&Response {
@ -227,13 +227,13 @@ impl Guest for Component {
.to_vec(),
}),
);
} else if message_json["path"] == "/http-proxy/register"
} else if message_json["path"] == "/register"
&& message_json["method"] == "POST"
{
let mut status = 204;
let Some(payload) = get_payload() else {
print_to_terminal(1, "/http-proxy/register POST with no bytes");
print_to_terminal(1, "/register POST with no bytes");
continue;
};
@ -282,10 +282,10 @@ impl Guest for Component {
.to_vec(),
}),
);
} else if message_json["path"] == "/http-proxy/register"
} else if message_json["path"] == "/register"
&& message_json["method"] == "DELETE"
{
print_to_terminal(1, "HERE IN /http-proxy/register to delete something");
print_to_terminal(1, "HERE IN /register to delete something");
let username = message_json["query_params"]["username"]
.as_str()
.unwrap_or("");
@ -325,7 +325,7 @@ impl Guest for Component {
.to_vec(),
}),
);
} else if message_json["path"] == "/http-proxy/serve/:username/*" {
} else if message_json["path"] == "/serve/:username/*" {
let username = message_json["url_params"]["username"]
.as_str()
.unwrap_or("");