()
| 31 | type Users []User |
| 32 | |
| 33 | func main() { |
| 34 | app := pine.New() |
| 35 | app.Get("/hello/:name", func(c *pine.Ctx) error { |
| 36 | params := new(MyParams) |
| 37 | err := c.BindParam("name", ¶ms.Name) |
| 38 | if err != nil { |
| 39 | return c.SendStatus(http.StatusBadRequest) |
| 40 | } |
| 41 | return c.SendString("Hello " + params.Name) |
| 42 | }) |
| 43 | |
| 44 | app.Get("/search", func(c *pine.Ctx) error { |
| 45 | query := new(Query) |
| 46 | err := c.BindQuery("query", query) |
| 47 | if err != nil { |
| 48 | return c.SendStatus(http.StatusBadRequest) |
| 49 | } |
| 50 | return c.SendString("you searched for " + string(*query)) |
| 51 | }) |
| 52 | |
| 53 | app.Post("/login", func(c *pine.Ctx) error { |
| 54 | user := new(User) |
| 55 | err := c.BindJSON(user) |
| 56 | if err != nil { |
| 57 | return c.SendStatus(http.StatusBadRequest) |
| 58 | } |
| 59 | return c.SendString("login in successful") |
| 60 | }) |
| 61 | |
| 62 | app.Post("/signUp", func(c *pine.Ctx) error { |
| 63 | request := new(Request) |
| 64 | err := c.BindJSON(request) |
| 65 | if err != nil { |
| 66 | return c.SendStatus(http.StatusBadRequest) |
| 67 | } |
| 68 | return c.SendString("User registered successfully") |
| 69 | }) |
| 70 | |
| 71 | app.Post("/migrate", func(c *pine.Ctx) error { |
| 72 | users := new(Users) |
| 73 | err := c.BindJSON(users) |
| 74 | if err != nil { |
| 75 | return c.SendStatus(http.StatusBadRequest) |
| 76 | } |
| 77 | return c.SendString("migration was a success!") |
| 78 | }) |
| 79 | // Start the server on port 3000 |
| 80 | log.Fatal(app.Start(":3001")) |
| 81 | } |
nothing calls this directly
no test coverage detected