web server now serves inlined resources as static assets
This commit is contained in:
parent
9733bd2f07
commit
8e12c4869b
|
@ -1,8 +1,8 @@
|
||||||
FROM golang:1.20-alpine
|
FROM golang:1.20-alpine
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
|
COPY go.mod index.html main.go ./
|
||||||
COPY go.mod index-inlined-minified.html main.go ./
|
ADD assets ./assets/
|
||||||
RUN go mod download && go mod verify
|
RUN go mod download && go mod verify
|
||||||
|
|
||||||
RUN go build -v -o /usr/local/bin/app ./...
|
RUN go build -v -o /usr/local/bin/app ./...
|
||||||
|
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
File diff suppressed because one or more lines are too long
|
@ -7,14 +7,14 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<meta name="darkreader-lock"> <!-- Request dark reader to ignore this site. See: https://github.com/darkreader/darkreader/blob/main/CONTRIBUTING.md#disabling-dark-reader-on-your-site -->
|
<meta name="darkreader-lock"> <!-- Request dark reader to ignore this site. See: https://github.com/darkreader/darkreader/blob/main/CONTRIBUTING.md#disabling-dark-reader-on-your-site -->
|
||||||
<title>Montehaselino - Automatic Status Response</title>
|
<title>Montehaselino - Automatic Status Response</title>
|
||||||
<link href="master.css" rel="stylesheet"/>
|
<link href="assets/master.css" rel="stylesheet"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<div id="cloud1"></div>
|
<div id="cloud1"></div>
|
||||||
<div id="cloud2"></div>
|
<div id="cloud2"></div>
|
||||||
<div id="cloud3"></div>
|
<div id="cloud3"></div>
|
||||||
<img id="mountain" src="res/svg/error-page-overlay.svg" alt="">
|
<img id="mountain" src="assets/res/svg/error-page-overlay.svg" alt="">
|
||||||
<div id="rocks"></div>
|
<div id="rocks"></div>
|
||||||
<h1>ERROR</h1>
|
<h1>ERROR</h1>
|
||||||
<h2>{{.Code}}</h2>
|
<h2>{{.Code}}</h2>
|
7
main.go
7
main.go
|
@ -52,7 +52,7 @@ func genStatus(request string) StatusData {
|
||||||
// create and init page status
|
// create and init page status
|
||||||
var status StatusData
|
var status StatusData
|
||||||
status.Code = "500"
|
status.Code = "500"
|
||||||
status.Message = fmt.Sprintf("Invalid error response code recieved: %.5s[..]", request)
|
status.Message = fmt.Sprintf("Invalid error response code recieved: `%.5s`", request)
|
||||||
status.Response = 500
|
status.Response = 500
|
||||||
|
|
||||||
// check if we have a valid status code
|
// check if we have a valid status code
|
||||||
|
@ -74,7 +74,7 @@ func genStatus(request string) StatusData {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// load template
|
// load template
|
||||||
tmpl, err := template.ParseFiles("index-inlined-minified.html")
|
tmpl, err := template.ParseFiles("index.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,9 @@ func main() {
|
||||||
tmpl.Execute(w, status)
|
tmpl.Execute(w, status)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// serve static assets
|
||||||
|
http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets"))))
|
||||||
|
|
||||||
var address = fmt.Sprintf("%s:%s", os.Getenv("BIND"), os.Getenv("PORT"))
|
var address = fmt.Sprintf("%s:%s", os.Getenv("BIND"), os.Getenv("PORT"))
|
||||||
|
|
||||||
log.Fatal(http.ListenAndServe(address, nil))
|
log.Fatal(http.ListenAndServe(address, nil))
|
||||||
|
|
Loading…
Reference in New Issue