Golang MVC: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Zeile 11: | Zeile 11: | ||
http.ListenAndServe(":9000", router) | http.ListenAndServe(":9000", router) | ||
} | } | ||
</pre> | |||
==router.go== | ==router.go== | ||
<pre> | <pre> |
Version vom 10. Januar 2025, 00:35 Uhr
main.go
package main import ( "net/http" ) func main() { router := newRouter() http.ListenAndServe(":9000", router) }
router.go
package main import ( "net/http" ) package main import ( "fmt" "net/http" ) func start(h http.ResponseWriter, r * http.Request) { fmt.Fprint(h,"Thorsten"); } func router() *http.ServeMux { router := http.NewServeMux() router.HandleFunc("/", start) return router }
controller.go
package main import ( "fmt" "net/http" ) func start(h http.ResponseWriter, r * http.Request) { fmt.Fprint(h,"Thorsten"); }