12345678910111213141516171819202122232425 |
- package server
- import (
- "net/http"
- "github.com/labstack/echo/v4"
- )
- func NewServer(s Server) *echo.Echo {
- e := echo.New()
- e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
- if err := next(c); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
- }
- return nil
- }
- })
- e.GET("/api", s.watchUpdates)
- e.POST("/api/:type", s.create)
- e.DELETE("/api/:type/:namespace/:name", s.delete)
- return e
- }
|