url refactoring

This commit is contained in:
Devaev Maxim 2019-04-27 01:58:21 +03:00
parent a89612e5ac
commit c40f13e2d7
10 changed files with 29 additions and 29 deletions

View File

@ -55,9 +55,9 @@ http {
server_name localhost;
#PROD include /etc/kvmd/nginx/ssl.conf;
auth_request /auth;
auth_request /auth_check;
location = /auth {
location = /auth_check {
internal;
proxy_pass http://kvmd/auth/check;
proxy_pass_request_body off;
@ -95,18 +95,18 @@ http {
auth_request off;
}
location /kvmd/ws {
rewrite ^/kvmd/ws$ /ws break;
rewrite ^/kvmd/ws\?(.*)$ /ws?$1 break;
location /api/ws {
rewrite ^/api/ws$ /ws break;
rewrite ^/api/ws\?(.*)$ /ws?$1 break;
proxy_pass http://kvmd;
include /etc/kvmd/nginx/loc-proxy.conf;
include /etc/kvmd/nginx/loc-websocket.conf;
auth_request off;
}
location /kvmd/msd/write {
rewrite ^/kvmd/msd/write$ /msd/write break;
rewrite ^/kvmd/msd/write\?(.*)$ /msd/write?$1 break;
location /api/msd/write {
rewrite ^/api/msd/write$ /msd/write break;
rewrite ^/api/msd/write\?(.*)$ /msd/write?$1 break;
proxy_pass http://kvmd;
include /etc/kvmd/nginx/loc-proxy.conf;
limit_rate 6250k;
@ -116,9 +116,9 @@ http {
auth_request off;
}
location /kvmd/log {
rewrite ^/kvmd/log$ /log break;
rewrite ^/kvmd/log\?(.*)$ /log?$1 break;
location /api/log {
rewrite ^/api/log$ /log break;
rewrite ^/api/log\?(.*)$ /log?$1 break;
proxy_pass http://kvmd;
include /etc/kvmd/nginx/loc-proxy.conf;
proxy_read_timeout 7d;
@ -128,9 +128,9 @@ http {
auth_request off;
}
location /kvmd {
rewrite ^/kvmd$ / break;
rewrite ^/kvmd/(.*)$ /$1 break;
location /api {
rewrite ^/api$ / break;
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://kvmd;
include /etc/kvmd/nginx/loc-proxy.conf;
auth_request off;

View File

@ -72,7 +72,7 @@
<table>
<tr class="server">
<td>Server:</td>
<td><a id="kvmd-meta-server-host" target="_blank" href="/kvmd/info"></a></td>
<td><a id="kvmd-meta-server-host" target="_blank" href="/api/info"></a></td>
</tr>
</table>
<hr>

View File

@ -45,7 +45,7 @@ function __setAppText() {
}
function __loadKvmdInfo() {
let http = tools.makeRequest("GET", "/kvmd/info", function() {
let http = tools.makeRequest("GET", "/api/info", function() {
if (http.readyState === 4) {
if (http.status === 200) {
let info = JSON.parse(http.responseText).result;
@ -101,7 +101,7 @@ function __makeApp(id, path, icon, name) {
}
function __logout() {
let http = tools.makeRequest("POST", "/kvmd/auth/logout", function() {
let http = tools.makeRequest("POST", "/api/auth/logout", function() {
if (http.readyState === 4) {
if (http.status === 200 || http.status === 401 || http.status === 403) {
document.location.href = "/login";

View File

@ -56,7 +56,7 @@ function Atx() {
var __clickButton = function(button, confirm_msg) {
wm.confirm(confirm_msg).then(function(ok) {
if (ok) {
let http = tools.makeRequest("POST", "/kvmd/atx/click?button=" + button, function() {
let http = tools.makeRequest("POST", "/api/atx/click?button=" + button, function() {
if (http.readyState === 4) {
if (http.status === 409) {
wm.error("Performing another ATX operation for other client.<br>Please try again later");

View File

@ -215,7 +215,7 @@ function Hid() {
var __clickResetButton = function() {
wm.confirm("Are you sure you want to reset HID (keyboard & mouse)?").then(function(ok) {
if (ok) {
let http = tools.makeRequest("POST", "/kvmd/hid/reset", function() {
let http = tools.makeRequest("POST", "/api/hid/reset", function() {
if (http.readyState === 4) {
if (http.status !== 200) {
wm.error("HID reset error:<br>", http.responseText);

View File

@ -35,7 +35,7 @@ function main() {
tools.setOnClick($("show-about-button"), () => wm.showWindow($("about-window")));
tools.setOnClick($("show-keyboard-button"), () => wm.showWindow($("keyboard-window")));
tools.setOnClick($("show-stream-button"), () => wm.showWindow($("stream-window")));
tools.setOnClick($("open-log-button"), () => window.open("/kvmd/log?seek=3600&follow=1", "_blank"));
tools.setOnClick($("open-log-button"), () => window.open("/api/log?seek=3600&follow=1", "_blank"));
wm.showWindow($("stream-window"));

View File

@ -57,7 +57,7 @@ function Msd() {
form_data.append("image_data", __image_file);
__upload_http = new XMLHttpRequest();
__upload_http.open("POST", "/kvmd/msd/write", true);
__upload_http.open("POST", "/api/msd/write", true);
__upload_http.upload.timeout = 5000;
__upload_http.onreadystatechange = __uploadStateChange;
__upload_http.upload.onprogress = __uploadProgress;
@ -74,7 +74,7 @@ function Msd() {
};
var __clickSwitchButton = function(to) {
let http = tools.makeRequest("POST", "/kvmd/msd/connect?to=" + to, function() {
let http = tools.makeRequest("POST", "/api/msd/connect?to=" + to, function() {
if (http.readyState === 4) {
if (http.status !== 200) {
wm.error("Switch error:<br>", http.responseText);
@ -101,7 +101,7 @@ function Msd() {
var __clickResetButton = function() {
wm.confirm("Are you sure you want to reset Mass Storage Device?").then(function(ok) {
if (ok) {
let http = tools.makeRequest("POST", "/kvmd/msd/reset", function() {
let http = tools.makeRequest("POST", "/api/msd/reset", function() {
if (http.readyState === 4) {
if (http.status !== 200) {
wm.error("MSD reset error:<br>", http.responseText);

View File

@ -46,7 +46,7 @@ function Session() {
let text = JSON.stringify(state.meta, undefined, 4).replace(/ /g, "&nbsp;").replace(/\n/g, "<br>");
$("about-meta").innerHTML = `
<span class="code-comment">// The Pi-KVM metadata.<br>
// You can get this json using handle <a target="_blank" href="/kvmd/info">/kvmd/info</a>.<br>
// You can get this json using handle <a target="_blank" href="/api/info">/api/info</a>.<br>
// In the standard configuration this data<br>
// is specified in the file /etc/kvmd/meta.yaml.</span><br>
<br>
@ -69,11 +69,11 @@ function Session() {
$("link-led").className = "led-yellow";
$("link-led").title = "Connecting...";
let http = tools.makeRequest("GET", "/kvmd/auth/check", function() {
let http = tools.makeRequest("GET", "/api/auth/check", function() {
if (http.readyState === 4) {
if (http.status === 200) {
let proto = (location.protocol === "https:" ? "wss" : "ws");
__ws = new WebSocket(`${proto}://${location.host}/kvmd/ws`);
__ws = new WebSocket(`${proto}://${location.host}/api/ws`);
__ws.onopen = __wsOpenHandler;
__ws.onmessage = __wsMessageHandler;
__ws.onerror = __wsErrorHandler;

View File

@ -187,7 +187,7 @@ function Streamer() {
var __clickResetButton = function() {
wm.confirm("Are you sure you want to reset stream?").then(function (ok) {
if (ok) {
let http = tools.makeRequest("POST", "/kvmd/streamer/reset", function() {
let http = tools.makeRequest("POST", "/api/streamer/reset", function() {
if (http.readyState === 4) {
if (http.status !== 200) {
wm.error("Can't reset stream:<br>", http.responseText);
@ -199,7 +199,7 @@ function Streamer() {
};
var __sendParam = function(name, value) {
let http = tools.makeRequest("POST", `/kvmd/streamer/set_params?${name}=${value}`, function() {
let http = tools.makeRequest("POST", `/api/streamer/set_params?${name}=${value}`, function() {
if (http.readyState === 4) {
if (http.status !== 200) {
wm.error("Can't configure stream:<br>", http.responseText);

View File

@ -45,7 +45,7 @@ function __login() {
} else {
let passwd = $("passwd-input").value;
let body = `user=${encodeURIComponent(user)}&passwd=${encodeURIComponent(passwd)}`;
let http = tools.makeRequest("POST", "/kvmd/auth/login", function() {
let http = tools.makeRequest("POST", "/api/auth/login", function() {
if (http.readyState === 4) {
if (http.status === 200) {
document.location.href = "/";