52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"git.proximination.com/pcpelatihan/wstempl/component"
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func main() {
|
|
port := ":8123"
|
|
router := chi.NewRouter()
|
|
|
|
router.Get("/", HandleHome)
|
|
router.Get("/satu", HandleFormSatu)
|
|
router.Get("/dua", HandleFormDua)
|
|
router.Get("/tiga", HandleFormTiga)
|
|
router.Get("/coba", HandleCoba)
|
|
|
|
server := http.Server{
|
|
Addr: port,
|
|
Handler: router,
|
|
}
|
|
|
|
fmt.Printf("server jalan di http://localhost%s", port)
|
|
|
|
if err := server.ListenAndServe(); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func HandleHome(w http.ResponseWriter, r *http.Request) {
|
|
component.HomePage().Render(r.Context(), w)
|
|
}
|
|
|
|
func HandleFormSatu(w http.ResponseWriter, r *http.Request) {
|
|
component.FormSatu().Render(r.Context(), w)
|
|
}
|
|
|
|
func HandleFormDua(w http.ResponseWriter, r *http.Request) {
|
|
component.FormDua().Render(r.Context(), w)
|
|
}
|
|
|
|
func HandleFormTiga(w http.ResponseWriter, r *http.Request) {
|
|
component.FormTiga().Render(r.Context(), w)
|
|
}
|
|
|
|
func HandleCoba(w http.ResponseWriter, r *http.Request) {
|
|
component.Try().Render(r.Context(), w)
|
|
}
|