diff --git a/assets/components/LogViewer/LogActionsToolbar.vue b/assets/components/LogViewer/LogActionsToolbar.vue
index 944ecc12..e2e4dca2 100644
--- a/assets/components/LogViewer/LogActionsToolbar.vue
+++ b/assets/components/LogViewer/LogActionsToolbar.vue
@@ -12,7 +12,7 @@
-
+
{{ $t("toolbar.download") }}
diff --git a/assets/components/LogViewer/LogEventSource.spec.ts b/assets/components/LogViewer/LogEventSource.spec.ts
index 28d3a0ec..36235b98 100644
--- a/assets/components/LogViewer/LogEventSource.spec.ts
+++ b/assets/components/LogViewer/LogEventSource.spec.ts
@@ -90,7 +90,7 @@ describe("", () => {
});
}
- const sourceUrl = "/api/logs/stream/localhost/abc?stdout=1&stderr=1";
+ const sourceUrl = "/api/hosts/localhost/containers/abc/logs/stream?stdout=1&stderr=1";
test("renders correctly", async () => {
const wrapper = createLogEventSource();
diff --git a/assets/composable/eventsource.ts b/assets/composable/eventsource.ts
index 41b9edb4..00119b28 100644
--- a/assets/composable/eventsource.ts
+++ b/assets/composable/eventsource.ts
@@ -85,7 +85,9 @@ export function useLogStream() {
console.debug(`Connecting to ${containerId} with params`, params);
es = new EventSource(
- withBase(`/api/logs/stream/${container.value.host}/${containerId}?${new URLSearchParams(params).toString()}`),
+ withBase(
+ `/api/hosts/${container.value.host}/containers/${containerId}/logs/stream?${new URLSearchParams(params).toString()}`,
+ ),
);
es.addEventListener("container-stopped", () => {
close();
@@ -118,7 +120,9 @@ export function useLogStream() {
const logs = await (
await fetch(
- withBase(`/api/logs/${container.value.host}/${containerId}?${new URLSearchParams(params).toString()}`),
+ withBase(
+ `/api/hosts/${container.value.host}/containers/${containerId}/logs?${new URLSearchParams(params).toString()}`,
+ ),
)
).text();
if (logs) {
diff --git a/internal/web/actions_test.go b/internal/web/actions_test.go
index 099c54ce..884667d5 100644
--- a/internal/web/actions_test.go
+++ b/internal/web/actions_test.go
@@ -34,58 +34,58 @@ func Test_handler_containerActions_stop(t *testing.T) {
mockedClient := get_mocked_client()
handler := createHandler(mockedClient, nil, Config{Base: "/", EnableActions: true, Authorization: Authorization{Provider: NONE}})
- req, err := http.NewRequest("POST", "/api/actions/stop/localhost/123", nil)
+ req, err := http.NewRequest("POST", "/api/hosts/localhost/containers/123/actions/stop", nil)
require.NoError(t, err, "Request should not return an error.")
rr := httptest.NewRecorder()
handler.ServeHTTP(rr, req)
- assert.Equal(t, rr.Code, 200)
+ assert.Equal(t, 200, rr.Code)
}
func Test_handler_containerActions_restart(t *testing.T) {
mockedClient := get_mocked_client()
handler := createHandler(mockedClient, nil, Config{Base: "/", EnableActions: true, Authorization: Authorization{Provider: NONE}})
- req, err := http.NewRequest("POST", "/api/actions/restart/localhost/123", nil)
+ req, err := http.NewRequest("POST", "/api/hosts/localhost/containers/123/actions/restart", nil)
require.NoError(t, err, "Request should not return an error.")
rr := httptest.NewRecorder()
handler.ServeHTTP(rr, req)
- assert.Equal(t, rr.Code, 200)
+ assert.Equal(t, 200, rr.Code)
}
func Test_handler_containerActions_unknown_action(t *testing.T) {
mockedClient := get_mocked_client()
handler := createHandler(mockedClient, nil, Config{Base: "/", EnableActions: true, Authorization: Authorization{Provider: NONE}})
- req, err := http.NewRequest("POST", "/api/actions/something-else/localhost/123", nil)
+ req, err := http.NewRequest("POST", "/api/hosts/localhost/containers/123/actions/something-else", nil)
require.NoError(t, err, "Request should not return an error.")
rr := httptest.NewRecorder()
handler.ServeHTTP(rr, req)
- assert.Equal(t, rr.Code, 500)
+ assert.Equal(t, 500, rr.Code)
}
func Test_handler_containerActions_unknown_container(t *testing.T) {
mockedClient := get_mocked_client()
handler := createHandler(mockedClient, nil, Config{Base: "/", EnableActions: true, Authorization: Authorization{Provider: NONE}})
- req, err := http.NewRequest("POST", "/api/actions/start/localhost/456", nil)
+ req, err := http.NewRequest("POST", "/api/hosts/localhost/containers/456/actions/start", nil)
require.NoError(t, err, "Request should not return an error.")
rr := httptest.NewRecorder()
handler.ServeHTTP(rr, req)
- assert.Equal(t, rr.Code, 404)
+ assert.Equal(t, 404, rr.Code)
}
func Test_handler_containerActions_start(t *testing.T) {
mockedClient := get_mocked_client()
handler := createHandler(mockedClient, nil, Config{Base: "/", EnableActions: true, Authorization: Authorization{Provider: NONE}})
- req, err := http.NewRequest("POST", "/api/actions/start/localhost/123", nil)
+ req, err := http.NewRequest("POST", "/api/hosts/localhost/containers/123/actions/start", nil)
require.NoError(t, err, "Request should not return an error.")
rr := httptest.NewRecorder()
handler.ServeHTTP(rr, req)
- assert.Equal(t, rr.Code, 200)
+ assert.Equal(t, 200, rr.Code)
}
diff --git a/internal/web/download_test.go b/internal/web/download_test.go
index 732f7071..6ad27402 100644
--- a/internal/web/download_test.go
+++ b/internal/web/download_test.go
@@ -17,7 +17,7 @@ import (
func Test_handler_download_logs(t *testing.T) {
id := "123456"
- req, err := http.NewRequest("GET", "/api/logs/download/localhost/"+id, nil)
+ req, err := http.NewRequest("GET", "/api/hosts/localhost/containers/"+id+"/logs/download", nil)
require.NoError(t, err, "NewRequest should not return an error.")
mockedClient := new(MockedClient)
diff --git a/internal/web/logs_test.go b/internal/web/logs_test.go
index 322a762b..91490d9c 100644
--- a/internal/web/logs_test.go
+++ b/internal/web/logs_test.go
@@ -20,7 +20,7 @@ import (
func Test_handler_streamLogs_happy(t *testing.T) {
id := "123456"
- req, err := http.NewRequest("GET", "/api/logs/stream/localhost/"+id, nil)
+ req, err := http.NewRequest("GET", "/api/hosts/localhost/containers/"+id+"/logs/stream", nil)
q := req.URL.Query()
q.Add("stdout", "true")
q.Add("stderr", "true")
@@ -44,7 +44,7 @@ func Test_handler_streamLogs_happy(t *testing.T) {
func Test_handler_streamLogs_happy_with_id(t *testing.T) {
id := "123456"
- req, err := http.NewRequest("GET", "/api/logs/stream/localhost/"+id, nil)
+ req, err := http.NewRequest("GET", "/api/hosts/localhost/containers/"+id+"/logs/stream", nil)
q := req.URL.Query()
q.Add("stdout", "true")
q.Add("stderr", "true")
@@ -68,7 +68,7 @@ func Test_handler_streamLogs_happy_with_id(t *testing.T) {
func Test_handler_streamLogs_happy_container_stopped(t *testing.T) {
id := "123456"
- req, err := http.NewRequest("GET", "/api/logs/stream/localhost/"+id, nil)
+ req, err := http.NewRequest("GET", "/api/hosts/localhost/containers/"+id+"/logs/stream", nil)
q := req.URL.Query()
q.Add("stdout", "true")
q.Add("stderr", "true")
@@ -89,7 +89,7 @@ func Test_handler_streamLogs_happy_container_stopped(t *testing.T) {
func Test_handler_streamLogs_error_finding_container(t *testing.T) {
id := "123456"
- req, err := http.NewRequest("GET", "/api/logs/stream/localhost/"+id, nil)
+ req, err := http.NewRequest("GET", "/api/hosts/localhost/containers/"+id+"/logs/stream", nil)
q := req.URL.Query()
q.Add("stdout", "true")
q.Add("stderr", "true")
@@ -109,7 +109,7 @@ func Test_handler_streamLogs_error_finding_container(t *testing.T) {
func Test_handler_streamLogs_error_reading(t *testing.T) {
id := "123456"
- req, err := http.NewRequest("GET", "/api/logs/stream/localhost/"+id, nil)
+ req, err := http.NewRequest("GET", "/api/hosts/localhost/containers/"+id+"/logs/stream", nil)
q := req.URL.Query()
q.Add("stdout", "true")
q.Add("stderr", "true")
@@ -130,7 +130,7 @@ func Test_handler_streamLogs_error_reading(t *testing.T) {
func Test_handler_streamLogs_error_std(t *testing.T) {
id := "123456"
- req, err := http.NewRequest("GET", "/api/logs/stream/localhost/"+id, nil)
+ req, err := http.NewRequest("GET", "/api/hosts/localhost/containers/"+id+"/logs/stream", nil)
require.NoError(t, err, "NewRequest should not return an error.")
@@ -143,10 +143,9 @@ func Test_handler_streamLogs_error_std(t *testing.T) {
mockedClient.AssertExpectations(t)
}
-// for /api/logs
func Test_handler_between_dates(t *testing.T) {
id := "123456"
- req, err := http.NewRequest("GET", "/api/logs/localhost/"+id, nil)
+ req, err := http.NewRequest("GET", "/api/hosts/localhost/containers/"+id+"/logs", nil)
require.NoError(t, err, "NewRequest should not return an error.")
from, _ := time.Parse(time.RFC3339, "2018-01-01T00:00:00Z")
diff --git a/internal/web/routes.go b/internal/web/routes.go
index c7fa36d5..f1c2ba3c 100644
--- a/internal/web/routes.go
+++ b/internal/web/routes.go
@@ -90,12 +90,12 @@ func createRouter(h *handler) *chi.Mux {
if h.config.Authorization.Provider != NONE {
r.Use(auth.RequireAuthentication)
}
- r.Get("/api/logs/stream/{host}/{id}", h.streamLogs)
- r.Get("/api/logs/download/{host}/{id}", h.downloadLogs)
- r.Get("/api/logs/{host}/{id}", h.fetchLogsBetweenDates)
+ r.Get("/api/hosts/{host}/containers/{id}/logs/stream", h.streamLogs)
+ r.Get("/api/hosts/{host}/containers/{id}/logs/download", h.downloadLogs)
+ r.Get("/api/hosts/{host}/containers/{id}/logs", h.fetchLogsBetweenDates)
r.Get("/api/events/stream", h.streamEvents)
if h.config.EnableActions {
- r.Post("/api/actions/{action}/{host}/{id}", h.containerActions)
+ r.Post("/api/hosts/{host}/containers/{id}/actions/{action}", h.containerActions)
}
r.Get("/api/releases", h.releases)
r.Get("/api/profile/avatar", h.avatar)