From 804f88f098697fe76d920ae4c7fb1588f205843f Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Sun, 29 Oct 2023 22:19:18 +0000 Subject: [PATCH] Some refactoring and styles --- src/App.svelte | 1 - src/components/RedirectCreator.svelte | 5 +- src/components/RedirectRow.svelte | 4 - src/components/RouteCreator.svelte | 5 +- src/components/RouteRow.svelte | 4 - src/views/VioletView.svelte | 232 +++++++++++++++----------- test-server/main.go | 84 ++++------ 7 files changed, 176 insertions(+), 159 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 6b1c7fd..d6fd8bb 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -171,7 +171,6 @@ #option-view { box-sizing: border-box; - padding: 16px; overflow-y: auto; height: 100%; flex-grow: 1; diff --git a/src/components/RedirectCreator.svelte b/src/components/RedirectCreator.svelte index 8f2d48d..5fdc09e 100644 --- a/src/components/RedirectCreator.svelte +++ b/src/components/RedirectCreator.svelte @@ -30,8 +30,9 @@ diff --git a/test-server/main.go b/test-server/main.go index 1977eb2..95a6b31 100644 --- a/test-server/main.go +++ b/test-server/main.go @@ -105,72 +105,50 @@ var serveApiCors = cors.New(cors.Options{ func apiServer(verify mjwt.Verifier) { r := http.NewServeMux() r.Handle("/v1/violet/route", hasPerm(verify, "violet:route", func(rw http.ResponseWriter, req *http.Request) { - json.NewEncoder(rw).Encode([]map[string]any{ - { - "src": "example.com", + m := make([]map[string]any, 0, 40) + for i := 0; i < 20; i++ { + m = append(m, map[string]any{ + "src": uuid.NewString() + ".example.com", "dst": "127.0.0.1:8080", "desc": "This is a test description", "flags": 181, "active": true, - }, - { - "src": "test.example.com", - "dst": "127.0.0.1:8081", - "desc": "This is a test description", - "flags": 17, - "active": true, - }, - { - "src": "example.org/hello", - "dst": "127.0.0.1:8082", - "desc": "This is a test description", - "flags": 16, - "active": true, - }, - { - "src": "test.example.org/hello", - "dst": "127.0.0.1:8083", - "desc": "This is a test description", - "flags": 15, - "active": true, - }, - }) - })) - r.Handle("/v1/violet/redirect", hasPerm(verify, "violet:redirect", func(rw http.ResponseWriter, req *http.Request) { - json.NewEncoder(rw).Encode([]map[string]any{ - { - "src": "example.org", - "dst": "127.0.0.1:8084", - "desc": "This is a test description", - "flags": 181, - "code": 307, - "active": true, - }, - { - "src": "test.example.org", + }) + } + for i := 0; i < 20; i++ { + m = append(m, map[string]any{ + "src": uuid.NewString() + ".example.org", "dst": "127.0.0.1:8085", "desc": "This is a test description", "flags": 17, - "code": 302, "active": true, - }, - { - "src": "example.org/hello", - "dst": "127.0.0.1:8086", + }) + } + json.NewEncoder(rw).Encode(m) + })) + r.Handle("/v1/violet/redirect", hasPerm(verify, "violet:redirect", func(rw http.ResponseWriter, req *http.Request) { + m := make([]map[string]any, 0, 40) + for i := 0; i < 20; i++ { + m = append(m, map[string]any{ + "src": uuid.NewString() + ".example.com", + "dst": "test1.example.com", "desc": "This is a test description", - "flags": 16, + "flags": 1, "code": 308, "active": true, - }, - { - "src": "test.example.org/hello", - "dst": "127.0.0.1:8087", + }) + } + for i := 0; i < 20; i++ { + m = append(m, map[string]any{ + "src": uuid.NewString() + ".example.org", + "dst": "test2.example.org", "desc": "This is a test description", - "flags": 15, - "code": 301, + "flags": 3, + "code": 307, "active": true, - }, - }) + }) + } + json.NewEncoder(rw).Encode(m) })) logger := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {