Skip to content

Instantly share code, notes, and snippets.

@iamjjanga-ouo
Last active March 19, 2021 08:30
Show Gist options
  • Save iamjjanga-ouo/58e375375e07e9d23aa7bbe391f18755 to your computer and use it in GitHub Desktop.
Save iamjjanga-ouo/58e375375e07e9d23aa7bbe391f18755 to your computer and use it in GitHub Desktop.
GoWeb: basic: HandlerFunc(f)
//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