-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroutes.go
78 lines (59 loc) · 2.39 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"github.com/gin-gonic/gin"
)
/**
* Set up all the routes
*/
func initializeRoutes(router *gin.Engine) {
// static assets
router.Static("/semantic", "./semantic")
router.Static("/assets", "./assets")
// HTML endpoints
router.GET("/", MainPage)
router.GET("/project/:id", ensureLoggedIn(), GetOneProject)
router.GET("/project/:id/untranslated/:lang", ensureLoggedIn(), GetOneProjectUntranslated)
// Import (upload) new messages file
router.POST("/project/:id/import", ensureLoggedIn(), PostNewFile)
router.GET("/add/new/project", ensureLoggedIn(), AddNewProjectForm)
// Group API routes together
api := router.Group("/api")
{
// update one term
api.POST("/terms/:id/:lang", ensureLoggedIn(), PostOneTerm)
// get one term
api.GET("/terms/:id", ensureLoggedIn(), GetAllTranslations)
// add new language to project
api.POST("/project/add/language", ensureLoggedIn(), PostNewLanguage)
// add new term to project
api.POST("/project/add/term", ensureLoggedIn(), PostNewTerm)
api.POST("/project/add", ensureLoggedIn(), PostCreateNewProject)
// delete one term and all its translations
api.DELETE("/terms/:id", ensureLoggedIn(), DeleteOneTerm)
// delete one project and a-a-a-a-a-l its terms and translations
api.DELETE("/project/:id", ensureLoggedIn(), DeleteOneProject)
// download one file
api.GET("/project/:project/file/:lang/:type" /* ensureLoggedIn(), */, DownloadFile)
}
// Group user related routes together
userRoutes := router.Group("/u")
{
// Handle the GET requests at /u/login
// Show the login page
// Ensure that the user is not logged in by using the middleware
userRoutes.GET("/login", ensureNotLoggedIn(), showLoginPage)
// Handle POST requests at /u/login
// Ensure that the user is not logged in by using the middleware
userRoutes.POST("/login", ensureNotLoggedIn(), performLogin)
// Handle GET requests at /u/logout
// Ensure that the user is logged in by using the middleware
userRoutes.GET("/logout", ensureLoggedIn(), logout)
// Handle the GET requests at /u/register
// Show the registration page
// Ensure that the user is not logged in by using the middleware
userRoutes.GET("/register", ensureNotLoggedIn(), showRegistrationPage)
// Handle POST requests at /u/register
// Ensure that the user is not logged in by using the middleware
userRoutes.POST("/register", ensureNotLoggedIn(), register)
}
}