🌱🏠 a cloud service to enable your own server (owned by you and running on your computer) to be accessible on the internet in seconds, no credit card required https://greenhouse.server.garden/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

73 lines
2.0 KiB

package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"strconv"
)
func registerHowtoRoutes(app *FrontendApp) {
app.handleWithSessionNotRequired(
"/using-your-own-domain-name-with-greenhouse",
func(responseWriter http.ResponseWriter, request *http.Request, session Session) {
templateData := struct {
Subdomain string
SubdomainDomain string
}{
SubdomainDomain: freeSubdomainDomain,
}
if session.TenantId != 0 {
tenant, err := app.Model.GetTenant(session.TenantId)
if err != nil {
app.unhandledError(responseWriter, err)
return
}
templateData.Subdomain = tenant.Subdomain
}
app.buildPageFromTemplate(responseWriter, session, "about-dns.html", templateData)
},
)
app.handleWithSessionNotRequired(
"/install-greenhouse-client-software-linux",
func(responseWriter http.ResponseWriter, request *http.Request, session Session) {
app.buildPageFromTemplate(responseWriter, session, "install.html", struct{}{})
},
)
serveScripts := []string{
"install.sh",
"uninstall.sh",
"install-macos.sh",
"uninstall-macos.sh",
}
for _, scriptFileName := range serveScripts {
app.handleWithSessionNotRequired(
fmt.Sprintf("/%s", scriptFileName),
func(responseWriter http.ResponseWriter, request *http.Request, session Session) {
file, err := os.OpenFile(fmt.Sprintf("frontend/static/%s", scriptFileName), os.O_RDONLY, 0755)
if err != nil {
log.Printf("/%s 404 not found: %+v", scriptFileName, err)
http.Error(responseWriter, "404 not found", http.StatusNotFound)
return
}
stat, err := file.Stat()
if err != nil {
log.Printf("/%s 500 internal server error: %+v", scriptFileName, err)
http.Error(responseWriter, "500 internal server error", http.StatusInternalServerError)
return
}
responseWriter.Header().Add("Content-Type", "application/x-sh")
responseWriter.Header().Add("Content-Length", strconv.Itoa(int(stat.Size())))
io.Copy(responseWriter, file)
},
)
}
}