init project
This commit is contained in:
35
internal/server/routes.go
Normal file
35
internal/server/routes.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
mikrobiologiHandler "api-lis/pkg/handlers/mikrobiologi"
|
||||
)
|
||||
|
||||
func (s *Server) RegisterRoutes() http.Handler {
|
||||
r := gin.Default()
|
||||
|
||||
r.GET("/hello", s.HelloWorldHandler)
|
||||
r.GET("/health", s.healthHandler)
|
||||
|
||||
v1 := r.Group("/api")
|
||||
|
||||
mikrobiologi := v1.Group("/mikrobiologi")
|
||||
{
|
||||
mikrobiologi.POST("/sendmikro", mikrobiologiHandler.SendDataLISMikro)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s *Server) HelloWorldHandler(c *gin.Context) {
|
||||
resp := make(map[string]string)
|
||||
resp["message"] = "Hello World"
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func (s *Server) healthHandler(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, s.db.Health())
|
||||
}
|
||||
Reference in New Issue
Block a user