Flow now works

This commit is contained in:
2024-11-17 20:40:50 +01:00
parent 157896d5d7
commit 6ae65e9169
8 changed files with 144 additions and 276 deletions

View File

@@ -1,6 +1,8 @@
package controllers
import (
"fmt"
"html"
"html/template"
"log"
"net/http"
@@ -9,6 +11,13 @@ import (
)
func Index(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
w.WriteHeader(http.StatusNotFound)
fmt.Fprintf(w, "Error: 404 %s not found.", html.EscapeString(r.URL.Path))
return
}
lp := filepath.Join("application", "layouts", "main.html")
fp := filepath.Join("application", "views", "index.html")

View File

@@ -10,7 +10,7 @@ import (
"risklet/db"
)
func Advanced(w http.ResponseWriter, r *http.Request) {
func ThankYou(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
handleAdvancedGet(w, r)
} else if r.Method == "POST" {
@@ -43,12 +43,11 @@ func handleAdvancedPost(w http.ResponseWriter, r *http.Request) {
}
func handleAdvancedGet(w http.ResponseWriter, r *http.Request) {
companyId := r.PathValue("companyId")
lp := filepath.Join("application", "layouts", "main.html")
fp := filepath.Join("application", "views", "advanced.html")
fp := filepath.Join("application", "views", "thankyou.html")
log.Println("Hitting Advanced")
log.Println("Hitting ThankYou")
// Return a 404 if the template doesn't exist
info, err := os.Stat(fp)
@@ -74,7 +73,7 @@ func handleAdvancedGet(w http.ResponseWriter, r *http.Request) {
return
}
err = tmpl.ExecuteTemplate(w, "main.html", companyId)
err = tmpl.ExecuteTemplate(w, "main.html", nil)
if err != nil {
log.Print(err.Error())
http.Error(w, http.StatusText(500), 500)