-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
83 lines (75 loc) · 3.38 KB
/
server.go
File metadata and controls
83 lines (75 loc) · 3.38 KB
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
79
80
81
82
83
package main
import (
"fmt"
"net/http"
"runtime"
"github.com/gin-gonic/gin"
"github.com/readthecodes/code-push-goserver/routes"
)
func main() {
// 使用多核
runtime.GOMAXPROCS(runtime.NumCPU())
// 生成一个gin实例
app := gin.Default()
app.LoadHTMLGlob("templates/*")
// 配置路由
// general
app.GET("/", routes.IndexView)
app.GET("/tokens", routes.TokenGetView)
app.GET("/updateCheck", routes.UpdateCheckView)
app.POST("/reportStatus/download", routes.ReportDownloadView)
app.POST("/reportStatus/deploy", routes.ReportDeployView)
app.POST("/authenticated", routes.AuthenticatedView)
// auth
app.GET("/auth/login", routes.LoginWebView)
app.POST("/auth/login", routes.LoginPostView)
app.POST("/auth/logout", routes.LogoutView)
app.GET("/auth/link", routes.LinkView)
app.GET("/auth/register", routes.RegisterView)
// accessKeys
app.GET("/accessKeys/", routes.AccessKeysGetView)
app.POST("/accessKeys/", routes.AccessKeysPostView)
app.DELETE("/accessKeys/:name", routes.AccessKeysDeleteView)
app.PATCH("/accessKeys/:name", routes.AccessKeysPatchView)
// sessions
app.DELETE("/sessions/:machineName", routes.SessionDeleteView)
// account
app.GET("/account", routes.AccountGetView)
// users
app.GET("/users/", routes.UsersGetView)
app.POST("/users/", routes.UsersCreateView)
app.GET("/users/exists", routes.UsersExistsView)
app.POST("/users/registerCode", routes.RegisterCodeCreateView)
app.POST("/users/registerCode/exists", routes.RegisterCodeExistsView)
app.POST("/users/password", routes.UsersPasswordUpdateView)
// apps
app.GET("/apps/", routes.AppsListView)
app.POST("/apps/", routes.AppCreateView)
app.PATCH("/apps/:appName", routes.AppUpdateView)
app.DELETE("/apps/:appName", routes.AppDeleteView)
app.POST("/apps/:appName/transfer/:email", routes.AppTransferView)
app.GET("/apps/:appName/deployments", routes.DeploymentsListView)
app.POST("/apps/:appName/deployments", routes.DeploymentsAddView)
app.GET("/apps/:appName/deployments/:deploymentName", routes.DeploymentGetView)
app.PATCH("/apps/:appName/deployments/:deploymentName", routes.DeploymentUpdateView)
app.DELETE("/apps/:appName/deployments/:deploymentName", routes.DeploymentDeleteView)
app.POST("/apps/:appName/deployments/:deploymentName/release", routes.DeploymentReleaseCreateView)
app.PATCH("/apps/:appName/deployments/:deploymentName/release", routes.DeploymentReleaseUpdateView)
app.POST("/apps/:appName/deployments/:sourceDeploymentName/promote/:destDeploymentName", routes.DeploymentPromoteView)
app.POST("/apps/:appName/deployments/:deploymentName/rollback", routes.DeploymentRollbackView)
app.POST("/apps/:appName/deployments/:deploymentName/rollback/label", routes.DeploymentRollbackView)
app.GET("/apps/:appName/deployments/:deploymentName/metrics", routes.DeploymentMetricsView)
app.GET("/apps/:appName/deployments/:deploymentName/history", routes.DeploymentHistoryView)
app.DELETE("/apps/:appName/deployments/:deploymentName/history", routes.DeploymentHistoryDeleteView)
app.GET("/apps/:appName/collaborators", routes.CollaboratorsListView)
app.POST("/apps/:appName/collaborators/:email", routes.CollaboratorCreateView)
app.DELETE("/apps/:appName/collaborators/:email", routes.CollaboratorDeleteView)
server := &http.Server{
Addr: ":6666",
Handler: app,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
server.ListenAndServe()
}