MCPcopy
hub / github.com/fagongzi/manba / main

Function main

cmd/backend/backend.go:18–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16)
17
18func main() {
19 flag.Parse()
20
21 server := echo.New()
22 server.Use(md.Logger())
23
24 server.GET("/fail", func(c echo.Context) error {
25 sleep := c.QueryParam("sleep")
26 if sleep != "" {
27 time.Sleep(time.Second * time.Duration(format.MustParseStrInt(sleep)))
28 }
29
30 code := c.QueryParam("code")
31 if code != "" {
32 return c.String(format.MustParseStrInt(code), "OK")
33 }
34
35 return c.String(http.StatusOK, "OK")
36 })
37
38 server.GET("/check", func(c echo.Context) error {
39 return c.String(http.StatusOK, "OK")
40 })
41
42 server.GET("/header", func(c echo.Context) error {
43 name := c.QueryParam("name")
44 return c.String(http.StatusOK, c.Request().Header.Get(name))
45 })
46
47 server.GET("/host", func(c echo.Context) error {
48 return c.String(http.StatusOK, c.Request().Host)
49 })
50
51 server.GET("/error", func(c echo.Context) error {
52 return c.NoContent(http.StatusBadRequest)
53 })
54
55 server.GET("/v1/components/:id", func(c echo.Context) error {
56 value := make(map[string]interface{})
57 data := make(map[string]interface{})
58 user := make(map[string]interface{})
59 user["id"] = c.Param("id")
60 user["name"] = fmt.Sprintf("v1-name-%s", c.Param("id"))
61 data["user"] = user
62 data["source"] = *addr
63
64 value["code"] = "0"
65 value["data"] = data
66 return c.JSON(http.StatusOK, value)
67 })
68 server.GET("/v1/users/:id", func(c echo.Context) error {
69 user := make(map[string]interface{})
70 user["id"] = c.Param("id")
71 user["name"] = fmt.Sprintf("v1-name-%s", c.Param("id"))
72 user["source"] = *addr
73 return c.JSON(http.StatusOK, user)
74 })
75 server.GET("/v1/account/:id", func(c echo.Context) error {

Callers

nothing calls this directly

Calls 5

GetMethod · 0.80
RequestMethod · 0.80
StartMethod · 0.80
UseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected