/
routes.go
50 lines (41 loc) · 1.91 KB
/
routes.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
package app
import (
"github.com/fragmenta/router"
"github.com/send-to/server/src/files/actions"
"github.com/send-to/server/src/pages/actions"
"github.com/send-to/server/src/users/actions"
)
// Define routes for this app
func setupRoutes(r *router.Router) {
r.Add("/users", useractions.HandleIndex)
r.Add("/users/create", useractions.HandleCreateShow)
r.Add("/users/create", useractions.HandleCreate).Post()
r.Add("/users/login", useractions.HandleLoginShow)
r.Add("/users/login", useractions.HandleLogin).Post()
r.Add("/users/logout", useractions.HandleLogout).Post()
r.Add("/users/{id:[0-9]+}/update", useractions.HandleUpdateShow)
r.Add("/users/{id:[0-9]+}/update", useractions.HandleUpdate).Post()
r.Add("/users/{id:[0-9]+}/destroy", useractions.HandleDestroy).Post()
r.Add("/users/{name:.+}/key", useractions.HandleShowKey)
r.Add("/users/{id:[0-9]+}", useractions.HandleShow)
r.Add("/users/{name:.+}", useractions.HandleShowName)
r.Add("/pages", pageactions.HandleIndex)
r.Add("/pages/create", pageactions.HandleCreateShow)
r.Add("/pages/create", pageactions.HandleCreate).Post()
r.Add("/pages/{id:[0-9]+}/update", pageactions.HandleUpdateShow)
r.Add("/pages/{id:[0-9]+}/update", pageactions.HandleUpdate).Post()
r.Add("/pages/{id:[0-9]+}/destroy", pageactions.HandleDestroy).Post()
r.Add("/pages/{id:[0-9]+}", pageactions.HandleShow)
r.Add("/files", fileactions.HandleIndex)
r.Add("/files/create", fileactions.HandleCreate).Post()
r.Add("/files/{id:[0-9]+}/update", fileactions.HandleUpdateShow)
r.Add("/files/{id:[0-9]+}/update", fileactions.HandleUpdate).Post()
r.Add("/files/{id:[0-9]+}/destroy", fileactions.HandleDestroy).Post()
r.Add("/files/{id:[0-9]+}/download", fileactions.HandleDownload)
// Set the default file handler
r.FileHandler = fileHandler
r.ErrorHandler = errHandler
r.Add("/favicon.ico", fileHandler)
// Add the custom page route
r.Add("/{path:[a-z0-9]?}", pageactions.HandleShowPath)
}