go-htmx-examples/deleterow/handlers.go

28 lines
526 B
Go
Raw Normal View History

2023-04-19 13:23:56 +00:00
package deleterow
import (
"fmt"
"net/http"
"strings"
)
type user struct {
name, email, id string
}
func Handlers(prefix string, mux *http.ServeMux) {
mux.HandleFunc(prefix+"/", index)
mux.HandleFunc(prefix+"/contact/", deleteUser)
}
func index(w http.ResponseWriter, r *http.Request) {
// Load users
Index().Render(r.Context(), w)
}
func deleteUser(w http.ResponseWriter, r *http.Request) {
segments := strings.Split(r.URL.Path, "/")
userID := segments[len(segments)-1]
fmt.Println("Delete user: ", userID)
}