From 95d08e57cefde33ba1560eb4a1e1ffd6b85c9390 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Fri, 17 Jan 2025 12:07:23 +0100 Subject: [PATCH] feat: add HTTPRoute --- comics/main.go | 7 ++++++- deploy/kustomization.yaml | 1 + deploy/resources/routes.yaml | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 deploy/resources/routes.yaml diff --git a/comics/main.go b/comics/main.go index b0a61a3..88e874d 100644 --- a/comics/main.go +++ b/comics/main.go @@ -28,11 +28,16 @@ type ImageReference struct { func init() { router := spinhttp.NewRouter() - router.GET("/monkeyuser", monkeyUserComic) + router.GET("/comics/random", randomComic) + router.GET("/comics/monkeyuser", monkeyUserComic) spinhttp.Handle(router.ServeHTTP) } +func randomComic(w http.ResponseWriter, re *http.Request, params httprouter.Params) { + monkeyUserComic(w, re, params) +} + func monkeyUserComic(w http.ResponseWriter, re *http.Request, _ httprouter.Params) { indexResponse, err := spinhttp.Get("https://www.monkeyuser.com/index.json") if err != nil { diff --git a/deploy/kustomization.yaml b/deploy/kustomization.yaml index 43f16c2..fa692ac 100644 --- a/deploy/kustomization.yaml +++ b/deploy/kustomization.yaml @@ -6,4 +6,5 @@ namespace: functions resources: - resources/namespace.yaml - resources/executor.yaml + - resources/routes.yaml - apps/comics.yaml diff --git a/deploy/resources/routes.yaml b/deploy/resources/routes.yaml new file mode 100644 index 0000000..ce8c1ce --- /dev/null +++ b/deploy/resources/routes.yaml @@ -0,0 +1,18 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: functions-https +spec: + parentRefs: + - name: contour + sectionName: https + namespace: projectcontour + hostnames: + - "functions.icb4dc0.de" + rules: + - matches: + - path: + value: "/comics" + backendRefs: + - name: comics + port: 80