Sign inSign up

wadghulegaurav/go-rest-api

By wadghulegaurav

•Updated over 3 years ago

go rest api example

Image
0

995

wadghulegaurav/go-rest-api repository overview

⁠go rest api

package main

import ( "fmt" "log" "net/http" )

func homePage(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Welcome to the HomePage!") fmt.Println("Endpoint Hit: homePage") } func accountPage(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Welcome to the accountPage!") fmt.Println("Endpoint Hit: accountPage") } func aboutPage(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Welcome to the aboutPage!") fmt.Println("Endpoint Hit: aboutPage") } func contactUsPage(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Welcome to the contactUsPage!") fmt.Println("Endpoint Hit: contactUsPage") }

func handleRequests() { http.HandleFunc("/", homePage) http.HandleFunc("/accounts", accountPage) http.HandleFunc("/about", aboutPage) http.HandleFunc("/contact", contactUsPage) log.Fatal(http.ListenAndServe(":5000", nil)) }

func main() { handleRequests() }

Tag summary

Content type

Image

Digest

sha256:3ac0d495b…

Size

354.6 MB

Last updated

over 3 years ago

docker pull wadghulegaurav/go-rest-api