Last active
March 19, 2021 08:30
-
-
Save iamjjanga-ouo/58e375375e07e9d23aa7bbe391f18755 to your computer and use it in GitHub Desktop.
GoWeb: basic: HandlerFunc(f)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//HandlerFunc(f) | |
// The HandlerFunc type is an adapter to allow the use of ordinary functions as HTTP handlers. | |
// If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f. | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func myFunc(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, ` | |
<!DOCTYPE html> | |
<html> | |
<head> | |
Hi | |
</head> | |
<body> | |
<h1>My name is Iamjjanga!</h1> | |
<p> gin is installed now</p> | |
</body> | |
</html> | |
`) | |
} | |
func main() { | |
http.ListenAndServe("localhost:8080", http.HandlerFunc(myFunc)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment