Last active
March 18, 2020 07:35
-
-
Save junaidrahim/d26db940fd36a8e36caebfb26d3117bb to your computer and use it in GitHub Desktop.
API Example
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hi there") | |
} | |
func main() { | |
fmt.Println("Starting server on port 3000") | |
// run the handler function when a request | |
// to the "/" endpoint is made | |
http.HandleFunc("/", handler) | |
log.Fatal(http.ListenAndServe(":3000", nil)) // start the server | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment