Skip to content

Commit

Permalink
feat: return name and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nanami69 committed Apr 27, 2023
1 parent 8410553 commit 618343f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
25 changes: 6 additions & 19 deletions backend/main.go
Expand Up @@ -10,27 +10,13 @@ import (
"github.com/labstack/echo/v4/middleware"
)

type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
}

func getUser(c echo.Context) error {
// id := c.Param("id")
// ダミーデータとしてユーザーを返す
user := &User{
ID: 1,
Name: "John Doe",
Email: "john@example.com",
}
return c.JSON(http.StatusOK, user)
}

func registerCinema(c echo.Context) error {
// データベースの登録と緯度経度算出処理
var req struct {
Address string `json:"address"`
Name string `json:"name"`
Address string `json:"address"`
PhotoURL string `json:"photo_url"`
Comment string `json:"comment"`
}
if err := c.Bind(&req); err != nil {
return err
Expand All @@ -42,8 +28,10 @@ func registerCinema(c echo.Context) error {
}

return c.JSON(http.StatusOK, map[string]string{
"name": req.Name,
"lat": lat,
"lng": lng,
"comment": req.Comment,
})
}

Expand Down Expand Up @@ -93,7 +81,6 @@ func main() {
// CORSの設定(デプロイ前に設定を見直す)
e.Use(middleware.CORS())
// ルーティングの設定
e.GET("/users/:id", getUser)
e.POST("/register-cinema", registerCinema)
// サーバーの起動
e.Logger.Fatal(e.Start(":8080"))
Expand Down
2 changes: 1 addition & 1 deletion frontend
Submodule frontend updated from c5ca27 to 0a0156

0 comments on commit 618343f

Please sign in to comment.