Skip to content

Commit

Permalink
feat: Add a route to sync Contentstack data
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Dec 26, 2024
1 parent 31fc289 commit 6d24eed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/server/handle-routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func HandleRoutes(mux *http.ServeMux, apiPath string) {
apiRoute(mux, apiPath, "/content-type", "GET", v1.GetContentType)
apiRoute(mux, apiPath, "/global-fields", "GET", v1.GetGlobalFields)
apiRoute(mux, apiPath, "/locales", "GET", v1.GetLocales)
apiRoute(mux, apiPath, "/sync", "POST", v1.Sync)
}

func apiRoute(
Expand Down
20 changes: 20 additions & 0 deletions cmd/server/routes/v1/sync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v1

import (
"fmt"
"net/http"

"github.com/Dobefu/csb/cmd/cs_sdk/functions"
"github.com/Dobefu/csb/cmd/server/utils"
)

func Sync(w http.ResponseWriter, r *http.Request) {
err := functions.Sync(false)

if err != nil {
utils.PrintError(w, err, false)
return
}

fmt.Fprint(w, string(`{"error": null}`))
}

0 comments on commit 6d24eed

Please sign in to comment.