-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
63 lines (50 loc) · 1.82 KB
/
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
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
package main
import (
"log"
"net/http"
"ulfr/config"
"ulfr/controllers"
"github.com/julienschmidt/httprouter"
"github.com/rs/cors"
)
func main() {
controllers.Init()
c := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"POST", "GET", "OPTIONS"},
AllowedHeaders: []string{"Content-Type"},
})
log.Println("Server started on localhost:8080")
if err := http.ListenAndServe(":"+config.Port, c.Handler(Routes())); err != nil {
log.Fatal(err)
}
}
func Routes() *httprouter.Router {
router := httprouter.New()
// Fire Routes
router.NotFound = http.HandlerFunc(controllers.FireULFR)
router.POST("/fire", controllers.Fire{}.Trigger)
router.GET("/fire", controllers.Fire{}.Index)
router.GET("/fire/show/:id", controllers.Fire{}.Get)
router.GET("/fire/delete/:id", controllers.Fire{}.Delete)
// Dashboard Routes
router.GET("/dashboard", controllers.Dashboard{}.Index)
// Domain Routes
router.GET("/domain", controllers.Domain{}.Index)
router.GET("/domain/create", controllers.Domain{}.Add)
router.POST("/domain/create", controllers.Domain{}.Create)
router.GET("/domain/delete/:id", controllers.Domain{}.Delete)
router.GET("/domain/update/:id", controllers.Domain{}.Get)
router.POST("/domain/update/:id", controllers.Domain{}.Update)
// Path Routes
router.GET("/path", controllers.Path{}.Index)
router.GET("/path/create", controllers.Path{}.Add)
router.POST("/path/create", controllers.Path{}.Create)
router.GET("/path/delete/:id", controllers.Path{}.Delete)
router.GET("/path/update/:id", controllers.Path{}.Get)
router.POST("/path/update/:id", controllers.Path{}.Update)
// Static Routes
router.ServeFiles("/assets/*filepath", http.Dir("assets/"))
router.ServeFiles("/data/*filepath", http.Dir("data/"))
return router
}