first commit

This commit is contained in:
2025-04-23 09:29:23 +07:00
commit 76abeaf8ee
25 changed files with 1323 additions and 0 deletions

47
internal/server/routes.go Normal file
View File

@@ -0,0 +1,47 @@
package server
import (
datapoliklinikHandler "api-poliklinik/pkg/handlers/Poliklinik"
datapractitionerHandler "api-poliklinik/pkg/handlers/Practitioner"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"net/http"
)
func (s *Server) RegisterRoutes() http.Handler {
r := gin.Default()
r.GET("/", s.HelloWorldHandler)
r.GET("/health", s.healthHandler)
v1 := r.Group("/api")
Poliklinik := v1.Group("/poliklinik")
{
Poliklinik.GET("/getdata/statuspelayanan/:statuspelayanan", datapoliklinikHandler.GetDataPoliklinik)
}
Practitioner := v1.Group("/practitioner")
{
Practitioner.GET("/getdata", datapractitionerHandler.GetDataPractitioner)
}
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"}, // or specific domains like "http://example.com"
AllowMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowHeaders: []string{"Origin", "Content-Type"},
AllowCredentials: true,
}))
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())
}