Skip to content

Commit

Permalink
update vercel route
Browse files Browse the repository at this point in the history
  • Loading branch information
futugyou committed Jun 17, 2024
1 parent 3f36ae9 commit 7111aab
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 4 deletions.
27 changes: 25 additions & 2 deletions infr-project/api/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,40 @@ func PlatformDispatch(w http.ResponseWriter, r *http.Request) {
updatePlatform(r, w)
case "delete":
deletePlatform(r, w)
case "hook":
hookPlatform(r, w)
case "all":
allPlatform(r, w)
case "hook":
hookPlatform(r, w)
case "project":
createPlatformProject(r, w)
case "prodel":
deletePlatformProject(r, w)
case "proup":
updatePlatformProject(r, w)
default:
w.Write([]byte("system error"))
w.WriteHeader(500)
return
}
}

func updatePlatformProject(r *http.Request, w http.ResponseWriter) {
id := r.URL.Query().Get("id")
projectId := r.URL.Query().Get("project_id")
apiadapter.CreatePlatformProject(id, projectId, w, r)
}

func deletePlatformProject(r *http.Request, w http.ResponseWriter) {
id := r.URL.Query().Get("id")
projectId := r.URL.Query().Get("project_id")
apiadapter.DeletePlatformProject(id, projectId, w, r)
}

func createPlatformProject(r *http.Request, w http.ResponseWriter) {
id := r.URL.Query().Get("id")
apiadapter.CreatePlatformProject(id, "", w, r)
}

func hookPlatform(r *http.Request, w http.ResponseWriter) {
id := r.URL.Query().Get("id")
projectId := r.URL.Query().Get("project_id")
Expand Down
49 changes: 47 additions & 2 deletions infr-project/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,53 @@
}
},
{
"src": "/api/v1/platform/(?<id>[^/]+)/hook",
"dest": "/api/platform.go?id=$id&optype=hook",
"src": "/api/v1/platform/(?<id>[^/]+)/project/(?<project_id>[^/]+)/hook",
"dest": "/api/platform.go?id=$id&project_id=$project_id&optype=hook",
"methods": [
"PUT",
"OPTIONS"
],
"headers": {
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
"Access-Control-Allow-Headers": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Authorization, account-id",
"Access-Control-Expose-Headers": "Access-Control-Allow-Origin, Token, Content-Length, Access-Control-Allow-Headers, Content-Type"
}
},
{
"src": "/api/v1/platform/(?<id>[^/]+)/project",
"dest": "/api/platform.go?id=$id&optype=project",
"methods": [
"POST",
"OPTIONS"
],
"headers": {
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
"Access-Control-Allow-Headers": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Authorization, account-id",
"Access-Control-Expose-Headers": "Access-Control-Allow-Origin, Token, Content-Length, Access-Control-Allow-Headers, Content-Type"
}
},
{
"src": "/api/v1/platform/(?<id>[^/]+)/project/(?<project_id>[^/]+)project_id",
"dest": "/api/platform.go?id=$id&project_id=$project_id&optype=prodel",
"methods": [
"DELETE",
"OPTIONS"
],
"headers": {
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
"Access-Control-Allow-Headers": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Authorization, account-id",
"Access-Control-Expose-Headers": "Access-Control-Allow-Origin, Token, Content-Length, Access-Control-Allow-Headers, Content-Type"
}
},
{
"src": "/api/v1/platform/(?<id>[^/]+)/project/(?<project_id>[^/]+)project_id",
"dest": "/api/platform.go?id=$id&project_id=$project_id&optype=proup",
"methods": [
"PUT",
"OPTIONS"
Expand Down

0 comments on commit 7111aab

Please sign in to comment.