Skip to content

Commit

Permalink
put the response html into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelcmtd committed Feb 27, 2023
1 parent 5024711 commit 23d4544
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
redirector-arm
redirector
redirector-*
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
all: response.min.html

response.min.html: response.html
npx html-minifier --collapse-whitespace --remove-comments --remove-tag-whitespace --minify-css true --minify-js true -o $@ $<

clean:
rm -f response.min.html

.PHONY: all clean
16 changes: 4 additions & 12 deletions redirector.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
_ "embed"
"fmt"
"log"
"net/http"
Expand All @@ -11,19 +12,10 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)

func main() {
var response = `
<html>
<head>
<title>Redirecting...</title>
<script>window.location.protocol = 'https:';</script>
</head>
<body>
Just switch to https up there ↑
</body>
</html>
`
//go:embed response.min.html
var response string

func main() {
var totalReqs = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "redirector_total_requests",
Help: "Total number of HTTP requests coming in.",
Expand Down
10 changes: 10 additions & 0 deletions response.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<title>Redirecting...</title>
<script>window.location.protocol = 'https:';</script>
</head>
<body>
Just switch to https up there ↑
</body>
</html>
1 change: 1 addition & 0 deletions response.min.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><title>Redirecting...</title><script>window.location.protocol="https:"</script></head><body>Just switch to https up there ↑</body></html>

0 comments on commit 23d4544

Please sign in to comment.