// cms is a free and open source content management system.
package main
import (
"log"
"net/http"
"strings"
)
type App struct {
log *log.Logger
// NOTE: Concurrent read (only) is OK. This is never wrote (but defined on
// server startup).
handlers map[string]http.Handler
}
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
parts := strings.Split(r.URL.Path, "/")
if len(parts) < 2 {
http.NotFound(w, r)
return
}
namespace := parts[1]
if namespace == "" {
namespace = "user"
}
h, ok := a.handlers[namespace]
if !ok {
http.NotFound(w, r)
return
}
h.ServeHTTP(w, r)
}