2 // ========================LICENSE_START=================================
5 // Copyright (C) 2024: OpenInfra Foundation Europe
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // ========================LICENSE_END===================================
27 echo "github.com/labstack/echo/v4"
30 func RegisterHandlers(e *echo.Echo) {
31 // Handle Kong service and route endpoint mock responses here
32 e.POST("/services", func(c echo.Context) error {
33 body, err := io.ReadAll(c.Request().Body)
35 return c.String(http.StatusInternalServerError, "Error reading request body")
37 return c.String(http.StatusCreated, string(body))
40 e.POST("/services/api_id_apiName_helloworld/routes", func(c echo.Context) error {
41 body, err := io.ReadAll(c.Request().Body)
43 return c.String(http.StatusInternalServerError, "Error reading request body")
45 return c.String(http.StatusCreated, string(body))
48 e.POST("/services/api_id_apiName1_helloworld/routes", func(c echo.Context) error {
49 body, err := io.ReadAll(c.Request().Body)
51 return c.String(http.StatusInternalServerError, "Error reading request body")
53 return c.String(http.StatusCreated, string(body))
56 e.POST("/services/api_id_apiName2_helloworld/routes", func(c echo.Context) error {
57 body, err := io.ReadAll(c.Request().Body)
59 return c.String(http.StatusInternalServerError, "Error reading request body")
61 return c.String(http.StatusCreated, string(body))
64 e.POST("/services/api_id_apiName1_app/routes", func(c echo.Context) error {
65 body, err := io.ReadAll(c.Request().Body)
67 return c.String(http.StatusInternalServerError, "Error reading request body")
69 return c.String(http.StatusCreated, string(body))
72 e.POST("/services/api_id_apiName2_app/routes", func(c echo.Context) error {
73 body, err := io.ReadAll(c.Request().Body)
75 return c.String(http.StatusInternalServerError, "Error reading request body")
77 return c.String(http.StatusCreated, string(body))
80 e.POST("/routes", func(c echo.Context) error {
81 body, err := io.ReadAll(c.Request().Body)
83 return c.String(http.StatusInternalServerError, "Error reading request body")
85 return c.String(http.StatusCreated, string(body))
88 e.GET("/services", func(c echo.Context) error {
89 return c.String(http.StatusOK, "{}")
92 e.GET("/routes", func(c echo.Context) error {
93 return c.String(http.StatusOK, "{}")
96 e.DELETE("/routes/api_id_apiName_helloworld", func(c echo.Context) error {
97 return c.NoContent(http.StatusNoContent)
100 e.DELETE("/services/api_id_apiName_helloworld", func(c echo.Context) error {
101 return c.NoContent(http.StatusNoContent)
104 e.DELETE("/routes/api_id_apiName1_helloworld", func(c echo.Context) error {
105 return c.NoContent(http.StatusNoContent)
108 e.DELETE("/routes/api_id_apiName2_helloworld", func(c echo.Context) error {
109 return c.NoContent(http.StatusNoContent)
112 e.DELETE("/routes/api_id_apiName1_app", func(c echo.Context) error {
113 return c.NoContent(http.StatusNoContent)
116 e.DELETE("/routes/api_id_apiName2_app", func(c echo.Context) error {
117 return c.NoContent(http.StatusNoContent)
120 e.DELETE("/services/api_id_apiName1_helloworld", func(c echo.Context) error {
121 return c.NoContent(http.StatusNoContent)
124 e.DELETE("/services/api_id_apiName2_helloworld", func(c echo.Context) error {
125 return c.NoContent(http.StatusNoContent)
128 e.DELETE("/services/api_id_apiName1_app", func(c echo.Context) error {
129 return c.NoContent(http.StatusNoContent)
132 e.DELETE("/services/api_id_apiName2_app", func(c echo.Context) error {
133 return c.NoContent(http.StatusNoContent)