package main import ( "fmt" "html/template" "log" "net/http" ) func IndexHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello World! \n") // w.Write() } func RegisterHandler(w http.ResponseWriter, r *http.Request) { log.Println("Processing registration!") fmt.Fprintf(w, "Processing registration! \n") // w.Write() } func PrintRegisterHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Printing register etc! \n") // w.Write() } func PrintNewJobHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Printing job") //t := template.Must(template.ParseFiles("templates/header.html", "templates/navbar.html", "templates/jobs.html", "templates/footer.html")) t := template.Must(template.ParseFiles("templates/jobs.html", "templates/header.html", "templates/navbar.html", "templates/footer.html")) //t := template.New("job") //t := templ //fmt.Printf("%s", t) //t, err := template.ParseFiles("templates/jobs.html", "templates/header.html") //t, err := template.ParseFiles("templates/jobs.html") //t, err := t.ParseFiles("templates/jobs.html") //if err != nil { // log.Panic(err) //} err := t.Execute(w, nil) if err != nil { log.Panic(err) } } func AddNewJobHandler(w http.ResponseWriter, r *http.Request) { log.Printf("Add new job") err := r.ParseForm() if err != nil { log.Panic(err) } host := &Host{} err = decoder.Decode(host, r.PostForm) if err != nil { log.Panic(err) } log.Printf("%v", host) fmt.Fprintf(w, "%s", host.Url) Db.Debug().Save(host) }