initialize backend project

Signed-off-by: Tobias Erbshäußer <tobias@tesoft.dev>
This commit is contained in:
2026-05-24 09:31:18 +02:00
parent 126fde7151
commit 7c1e2fb228
6 changed files with 64 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
.idea
+15
View File
@@ -0,0 +1,15 @@
package main
import "net/http"
type ApiHandler struct {
}
func NewApiHandler() *ApiHandler {
// TODO
return &ApiHandler{}
}
func (api *ApiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// TODO
}
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+3
View File
@@ -0,0 +1,3 @@
module backend
go 1.25
+32
View File
@@ -0,0 +1,32 @@
package main
import (
"log"
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
staticFolder := os.Getenv("STATIC_FOLDER")
if staticFolder == "" {
staticFolder = "static"
}
fsHandler := http.FileServer(http.Dir(staticFolder))
apiHandler := NewApiHandler()
mux := http.NewServeMux()
mux.Handle("/", fsHandler)
mux.Handle("/api/", apiHandler)
log.Println("Listening on port", port)
err := http.ListenAndServe(":"+port, mux)
if err != nil {
log.Fatalln(err.Error())
}
}