MCPcopy Create free account
hub / github.com/BryanMwangi/pine / main

Function main

Examples/FileExample/main.go:11–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9)
10
11func 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}

Callers

nothing calls this directly

Calls 12

NewFunction · 0.92
NewFunction · 0.92
UseMethod · 0.80
FormFileMethod · 0.80
SendStatusMethod · 0.80
SaveFileMethod · 0.80
SendStringMethod · 0.80
StreamFileMethod · 0.80
SendFileMethod · 0.80
PostMethod · 0.45
GetMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected