do some basic things on /

This commit is contained in:
Jeff Carr 2025-06-30 04:43:38 -05:00
parent ce65cca994
commit 66e9297086
5 changed files with 50 additions and 27 deletions

29
Caddyfile.forge.wit.com Normal file
View File

@ -0,0 +1,29 @@
{
email forge@wit.com
debug
servers {
metrics
}
log {
output file /var/log/caddy/caddy.log {
roll_size 500mb
}
format json {
time_format iso8601
}
}
}
forge.wit.com {
encode zstd gzip
reverse_proxy localhost:2520
log {
output file /var/log/caddy/forge.wit.com.log {
roll_size 100mb
}
format json {
time_format iso8601
}
}
}

View File

@ -46,6 +46,12 @@ run: build
./forged --port 2233 --hostname forge.wit.com ./forged --port 2233 --hostname forge.wit.com
# setcap 'cap_net_bind_service=+ep' forged # allow the binary to open ports below 1024 # setcap 'cap_net_bind_service=+ep' forged # allow the binary to open ports below 1024
prod: build
make stop
cp forged /usr/bin/forged
make start
make log
goimports: goimports:
reset reset
goimports -w *.go goimports -w *.go

16
http.go
View File

@ -32,10 +32,10 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
log.Warn("forged REQUEST URL =", requrl, "msg =", len(msg)) log.Warn("forged REQUEST URL =", requrl, "msg =", len(msg))
if route == "/" { if route == "/" {
// indexHeader(w) w.Header().Set("Content-Type", "text")
// indexBodyStart(w) fmt.Fprintf(w, "go.wit.com/apps/utils/forged Version: %s\n", argv.Version())
// indexBodyScanConfig(w) fmt.Fprintf(w, "\n")
// indexDivEnd(w) listPatchsets(w)
return return
} }
if route == "/patchset" { if route == "/patchset" {
@ -58,6 +58,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} }
if route == "/goReference.svg" { if route == "/goReference.svg" {
w.Header().Set("Content-Type", "image/svg+xml")
writeFile(w, "goReference.svg") writeFile(w, "goReference.svg")
return return
} }
@ -90,9 +91,6 @@ func writeFile(w http.ResponseWriter, filename string) {
var repohtml string var repohtml string
repohtml = string(pfile) repohtml = string(pfile)
if filename == "goReference.svg" {
w.Header().Set("Content-Type", "image/svg+xml")
}
fmt.Fprintln(w, repohtml) fmt.Fprintln(w, repohtml)
log.Println("writeFile() found internal file:", filename) log.Println("writeFile() found internal file:", filename)
} }
@ -105,9 +103,9 @@ func badurl(w http.ResponseWriter, badurl string) {
fmt.Fprintln(w, " </head>") fmt.Fprintln(w, " </head>")
fmt.Fprintln(w, " <body>") fmt.Fprintln(w, " <body>")
fmt.Fprintln(w, " IPv4 IS NOT SUPPORTED<br>") fmt.Fprintln(w, " IPv4 IS NOT SUPPORTED<br>")
fmt.Fprintln(w, " MANY OF THESE REPOS REQUIRE IPv6.<br>") fmt.Fprintln(w, " FORGE REQUIRES IPv6.<br>")
fmt.Fprintln(w, " <br>") fmt.Fprintln(w, " <br>")
fmt.Fprintln(w, " bad url", badurl, "<a href=\"https://go.wit.com/\">redirecting</a>") fmt.Fprintln(w, " bad url", badurl, "<a href=\"https://forge.wit.com/\">redirecting</a>")
fmt.Fprintln(w, " </body>") fmt.Fprintln(w, " </body>")
fmt.Fprintln(w, "</html>") fmt.Fprintln(w, "</html>")
} }

View File

@ -1,18 +0,0 @@
package main
import (
"fmt"
"net/http"
)
func https() {
// http.HandleFunc("/", okHandler)
certPath := "/etc/letsencrypt/live/go.wit.com/fullchain.pem"
keyPath := "/etc/letsencrypt/live/go.wit.com/privkey.pem"
err := http.ListenAndServeTLS(":443", certPath, keyPath, nil)
if err != nil {
fmt.Println("Error starting HTTPS server:", err)
}
}

8
resources/uptime.html Normal file
View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
OKFORGE
</body>
</html>