portal/api/router/router.go

15 lines
342 B
Go
Raw Normal View History

2024-01-12 00:11:53 +00:00
package router
import "net/http"
type ProtocolRouter map[string]http.Handler
// Implement the ServeHTTP method on our new type
func (hs ProtocolRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if handler := hs[r.Host]; handler != nil {
handler.ServeHTTP(w, r)
} else {
http.Error(w, "Forbidden", 403) // Or Redirect?
}
}