github.com/kenshin579/tutorials-go/go-echo-server@v0.0.0-20230308085259-a57c47a93bb4/ping/route/http/ping_handler.go (about)

     1  package http
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/labstack/echo/v4"
     7  )
     8  
     9  type PingHandler struct{}
    10  
    11  func NewPingHandler(e *echo.Echo) PingHandler {
    12  	handler := PingHandler{}
    13  
    14  	e.GET("/ping", handler.Ping)
    15  
    16  	return handler
    17  }
    18  
    19  // Ping godoc
    20  // @ID PingHandler.Ping
    21  // @Tags Ping
    22  // @Summary Ping API
    23  // @Description Ping API
    24  // @Success 200 {string} string "pong 메시지를 리턴한다"
    25  // @Router /ping [get]
    26  func (p PingHandler) Ping(c echo.Context) error {
    27  	return c.String(http.StatusOK, "Pong")
    28  }