summaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorHorus_Arch2015-02-18 17:03:41 +0100
committerHorus_Arch2015-02-18 17:03:41 +0100
commitcb5f3037bb18403433c2cfd0271f6bea76906aca (patch)
tree448397529fdbd1660b12001918289e04aa1c7ea6 /handler.go
parentd6ab45e8ec5f26004b4efc07383245051d546bf3 (diff)
downloadstatuspage-cb5f3037bb18403433c2cfd0271f6bea76906aca.tar.gz
Reimplementation with gorilla toolkit.
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/handler.go b/handler.go
new file mode 100644
index 0000000..16640ae
--- /dev/null
+++ b/handler.go
@@ -0,0 +1,63 @@
+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)
+}