mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 10:46:50 +00:00
29 lines
689 B
Go
29 lines
689 B
Go
package server
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/labstack/gommon/log"
|
|
|
|
"github.com/rjNemo/rentease/internal/booking"
|
|
)
|
|
|
|
func handleSync(bs *booking.Service) echo.HandlerFunc {
|
|
return func(c echo.Context) error {
|
|
log.Info("received booking sync request from booking")
|
|
x := c.Request().Body
|
|
body, err := io.ReadAll(x)
|
|
if err != nil {
|
|
return c.String(http.StatusInternalServerError, err.Error())
|
|
}
|
|
b, err := bs.ParseFromApi(string(body))
|
|
if err != nil {
|
|
return c.String(http.StatusInternalServerError, err.Error())
|
|
}
|
|
log.Infof("created booking %q from %q", b.Name, b.Platform)
|
|
|
|
return c.JSON(http.StatusCreated, "👍")
|
|
}
|
|
}
|