penambahan template

This commit is contained in:
2025-07-25 09:40:58 +07:00
parent e976215239
commit 6c23369c06
5 changed files with 85 additions and 24 deletions

View File

@@ -1,27 +1,29 @@
package server
import (
"net/http"
"fmt"
"log"
"time"
"github.com/gin-gonic/gin"
"github.com/a-h/templ"
"io/fs"
"template_blueprint/cmd/web"
"github.com/coder/websocket"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"io/fs"
"log"
"net/http"
"template_blueprint/cmd/web"
patientHandler "template_blueprint/pkg/handlers/patient"
datapoliklinikHandler "template_blueprint/pkg/handlers/poliklinik"
"time"
)
func (s *Server) RegisterRoutes() http.Handler {
r := gin.Default()
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,
}))
r.GET("/", s.HelloWorldHandler)
r.GET("/websocket", s.websocketHandler)
@@ -29,26 +31,21 @@ func (s *Server) RegisterRoutes() http.Handler {
staticFiles, _ := fs.Sub(web.Files, "assets")
r.StaticFS("/assets", http.FS(staticFiles))
r.GET("/web", func(c *gin.Context) {
templ.Handler(web.HelloForm()).ServeHTTP(c.Writer, c.Request)
})
r.POST("/hello", func(c *gin.Context) {
web.HelloWebHandler(c.Writer, c.Request)
})
api := r.Group("/api")
patient := api.Group("/patient")
v1 := r.Group("/api")
patient := v1.Group("/patient")
{
patient.POST("/insertpatient", patientHandler.InsertPatient)
patient.GET("/getallpatient", patientHandler.GetAllPatient)
}
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,
}))
Poliklinik := v1.Group("/poliklinik")
{
Poliklinik.GET("/getdata/statuspelayanan/:statuspelayanan", datapoliklinikHandler.GetDataPoliklinik)
}
return r
}