Migrate to Chi router and add Norwegian Devigo demo
Major improvements: - Replace Gorilla Mux with Chi v5 router for better performance and cleaner code - Fix CSS/JS MIME type issues that prevented proper asset loading - Add built-in CORS middleware replacing manual OPTIONS handlers - Simplify routing with nested route syntax - Update URL parameter extraction from mux.Vars to chi.URLParam New Devigo demo: - Add production Norwegian sales training website (devigo.no) - Real-world Hugo-generated content with TailwindCSS - 39 insertr-enhanced elements for comprehensive CMS testing - Demonstrates international language support and B2B use cases - Fixed asset paths for localhost serving compatibility Technical benefits: - Automatic MIME type detection for static files - Reduced code complexity with built-in middleware - Better performance with lighter dependency stack - Production-ready CORS handling
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/insertr/insertr/internal/auth"
|
||||
"github.com/insertr/insertr/internal/content"
|
||||
"github.com/insertr/insertr/internal/db"
|
||||
@@ -97,8 +97,7 @@ func (h *ContentHandler) EnhanceSite(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// GetContent handles GET /api/content/{id}
|
||||
func (h *ContentHandler) GetContent(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
contentID := vars["id"]
|
||||
contentID := chi.URLParam(r, "id")
|
||||
siteID := r.URL.Query().Get("site_id")
|
||||
|
||||
if siteID == "" {
|
||||
@@ -366,8 +365,7 @@ func (h *ContentHandler) CreateContent(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// DeleteContent handles DELETE /api/content/{id}
|
||||
func (h *ContentHandler) DeleteContent(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
contentID := vars["id"]
|
||||
contentID := chi.URLParam(r, "id")
|
||||
siteID := r.URL.Query().Get("site_id")
|
||||
|
||||
if siteID == "" {
|
||||
@@ -403,8 +401,7 @@ func (h *ContentHandler) DeleteContent(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// GetContentVersions handles GET /api/content/{id}/versions
|
||||
func (h *ContentHandler) GetContentVersions(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
contentID := vars["id"]
|
||||
contentID := chi.URLParam(r, "id")
|
||||
siteID := r.URL.Query().Get("site_id")
|
||||
|
||||
if siteID == "" {
|
||||
@@ -456,8 +453,7 @@ func (h *ContentHandler) GetContentVersions(w http.ResponseWriter, r *http.Reque
|
||||
|
||||
// RollbackContent handles POST /api/content/{id}/rollback
|
||||
func (h *ContentHandler) RollbackContent(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
contentID := vars["id"]
|
||||
contentID := chi.URLParam(r, "id")
|
||||
siteID := r.URL.Query().Get("site_id")
|
||||
|
||||
if siteID == "" {
|
||||
|
||||
Reference in New Issue
Block a user