-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (26 loc) · 927 Bytes
/
main.go
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
package main
import (
"net/http"
"github.com/go-martini/martini"
"github.com/martini-contrib/binding"
)
func main() {
LoadDatabase()
StartAutoSave()
m := martini.Classic()
// API endpoints
m.Get("/app/report/:host", GetReports)
m.Post("/app/report", binding.Bind(InboundReport{}), FileReport)
m.Get("/app/suggest/:prefix", SuggestHosts)
// API endpoints for report actions
m.Post("/app/update/:reportID/ack", binding.Bind(ActionMeta{}), Acknowledge)
m.Post("/app/update/:reportID/fixed", binding.Bind(ActionMeta{}), Fixed)
m.Post("/app/update/:reportID/reject", binding.Bind(ActionMeta{}), Reject)
m.Post("/app/update/:reportID/delete", binding.Bind(ActionMeta{}), Delete)
// Serve up the report page
m.Get("/report/:host", func(req *http.Request, resp http.ResponseWriter) {
http.ServeFile(resp, req, "public/report.html")
})
m.Get("/test", func() string { return "test successful" })
m.Run()
}