42 lines
928 B
Go
42 lines
928 B
Go
package pages
|
|
|
|
import (
|
|
"embed"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
//go:embed templates/*
|
|
var content embed.FS
|
|
|
|
func InitHttpHandlers() {
|
|
http.HandleFunc("/{$}", homepage)
|
|
http.HandleFunc("/.well-known/autoconfig/mail/config-v1.1.xml", emailAutoconfig)
|
|
http.HandleFunc("/mail/config-v1.1.xml", emailAutoconfig)
|
|
http.HandleFunc("/wp-cli.sh", wpCliSh)
|
|
http.HandleFunc("/thisisfine", thisIsFine)
|
|
}
|
|
|
|
func wpCliSh(w http.ResponseWriter, _ *http.Request) {
|
|
cliScript := `#!/bin/bash
|
|
|
|
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
|
chmod +x wp-cli.phar
|
|
mv wp-cli.phar wp
|
|
./wp
|
|
`
|
|
|
|
w.Header().Set("Content-Type", "text/plain")
|
|
_, _ = io.WriteString(w, cliScript)
|
|
}
|
|
|
|
func thisIsFine(w http.ResponseWriter, _ *http.Request) {
|
|
thisIsFineFile, err := content.Open("templates/thisisfine.jpg")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "image/jpeg")
|
|
_, err = io.Copy(w, thisIsFineFile)
|
|
}
|