()
| 9 | ) |
| 10 | |
| 11 | func main() { |
| 12 | app := pine.New() |
| 13 | |
| 14 | app.Use(cors.New(cors.Config{ |
| 15 | AllowedOrigins: []string{"*"}, |
| 16 | })) |
| 17 | |
| 18 | app.Post("/upload", func(c *pine.Ctx) error { |
| 19 | _, header, err := c.FormFile("file") |
| 20 | if err != nil { |
| 21 | return c.SendStatus(http.StatusInternalServerError) |
| 22 | } |
| 23 | err = c.SaveFile(header) |
| 24 | if err != nil { |
| 25 | return c.SendStatus(http.StatusInternalServerError) |
| 26 | } |
| 27 | return c.SendString("successfully uploaded file: " + header.Filename) |
| 28 | }) |
| 29 | |
| 30 | app.Get("/stream", func(c *pine.Ctx) error { |
| 31 | return c.StreamFile("./benchmark.mp4") |
| 32 | }) |
| 33 | |
| 34 | app.Get("/send", func(c *pine.Ctx) error { |
| 35 | return c.SendFile("./server.log") |
| 36 | }) |
| 37 | |
| 38 | log.Fatal(app.Start(":3001")) |
| 39 | } |
nothing calls this directly
no test coverage detected