Golang MVC: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Die Seite wurde neu angelegt: „==main.go== <pre> package main import ( "net/http" ) func main() { router := newRouter() http.ListenAndServe(":9000", router) } ==router.go== <pre> package main import ( "net/http" ) func router() *http.ServeMux { router := http.NewServeMux() router.HandleFunc("/", start) return router } </pre> ==controller.go== <pre> package main import ( "fmt" "net/http" ) func start(h http.ResponseWriter, r * http.Request) { fmt.Fprint(h,"Thorsten"); }…“ |
|||
Zeile 19: | Zeile 19: | ||
"net/http" | "net/http" | ||
) | ) | ||
package main | |||
import ( | |||
"fmt" | |||
"net/http" | |||
) | |||
func start(h http.ResponseWriter, r * http.Request) { | |||
fmt.Fprint(h,"Thorsten"); | |||
} | |||
func router() *http.ServeMux { | func router() *http.ServeMux { | ||
Zeile 26: | Zeile 34: | ||
} | } | ||
</pre> | </pre> | ||
==controller.go== | ==controller.go== | ||
<pre> | <pre> |
Version vom 10. Januar 2025, 00:34 Uhr
main.go
package main import ( "net/http" ) func main() { router := newRouter() http.ListenAndServe(":9000", router) } ==router.go== <pre> 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"); }