1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
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 StaticHandler(w http.ResponseWrite, r *http.Request) {
}
*/
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.Println("Printing job")
job := mainTempl.Lookup("jobs.html")
err := job.ExecuteTemplate(w, "jobs.html", 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)
}
func ShowJobHandler(w http.ResponseWriter, r *http.Request) {
jobs := c.Entries()
for _, i := range jobs {
fmt.Fprintf(w, "Job: %v, Schedule: %v; Next %v; Prev %v \n", i.Job, i.Schedule, i.Next, i.Prev)
}
}
|