mirror of
				https://github.com/SourceFellows/gobuch.git
				synced 2025-11-04 07:36:19 +01: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