Skip to content

Commit

Permalink
fix cd command
Browse files Browse the repository at this point in the history
  • Loading branch information
cfi2017 committed Apr 9, 2020
1 parent b5cdc97 commit f2088a8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"os"
"strings"
"time"

"github.com/gin-contrib/cors"
Expand All @@ -24,7 +25,7 @@ func Start() error {
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"https://bl3.swiss.dev", "http://localhost:4200"},
AllowMethods: []string{"GET", "POST"},
AllowHeaders: []string{"Origin"},
AllowHeaders: []string{"Origin", "Content-Type"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: false,
MaxAge: 12 * time.Hour,
Expand All @@ -42,12 +43,14 @@ func Start() error {
})

r.POST("/cd", func(c *gin.Context) {
var body struct{ path string }
err := c.BindJSON(&body)
var body struct {
Pwd string `json:"pwd" binding:"required"`
}
err := c.Bind(&body)
if err != nil {
return
}
pwd = body.path
pwd = strings.TrimSuffix(body.Pwd, "/")
c.JSON(200, struct {
Pwd string `json:"pwd"`
}{Pwd: pwd})
Expand Down

0 comments on commit f2088a8

Please sign in to comment.