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

Function main

Examples/UsingPineClient/MainServer/main.go:15–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13}
14
15func main() {
16 app := pine.New()
17 app.Get("/hello", func(c *pine.Ctx) error {
18 message := map[string]string{
19 "message": "Hello World!",
20 }
21 api_key := c.Request.Header.Get("X-API-KEY")
22 fmt.Println("got api key ", api_key)
23 return c.JSON(message, 200)
24 })
25
26 app.Post("/send", func(c *pine.Ctx) error {
27 var body body
28 err := json.NewDecoder(c.Request.Body).Decode(&body)
29 if err != nil {
30 return err
31 }
32 body.Message = "Hello from main server " + body.Message
33 return c.JSON(body, 200)
34 })
35
36 // Start the server on port 3000
37 log.Fatal(app.Start(":3000"))
38}

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
GetMethod · 0.45
JSONMethod · 0.45
PostMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected