mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-08-03 13:12:16 +02:00
initial import
This commit is contained in:
3
microservices/http-registration/go.mod
Normal file
3
microservices/http-registration/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module golang.source-fellows.com/samples/httpregistration
|
||||
|
||||
go 1.13
|
21
microservices/http-registration/main.go
Normal file
21
microservices/http-registration/main.go
Normal file
@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
||||
type MyHandler struct{}
|
||||
|
||||
func (mh *MyHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
||||
writer.Write([]byte("Hello World (from ServeHTTP)"))
|
||||
}
|
||||
|
||||
func handleHttp(res http.ResponseWriter, req *http.Request) {
|
||||
res.Write([]byte("Hello World (from handleHttp)"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
//Anmeldung der HandlerFunc Implementierung
|
||||
http.HandleFunc("/func", handleHttp)
|
||||
//Anmeldung der Handler Interface Implementierung
|
||||
http.Handle("/handler", &MyHandler{})
|
||||
http.ListenAndServe(":8080", &MyHandler{})
|
||||
}
|
Reference in New Issue
Block a user