Microservices

Microservices

Very simple service

package main
import "net/http"
import "log"
func main() {
http.HandleFunc("/", func(http.ResponseWriter, *http.Request) {
log.Println("Hello, world");
})
http.ListenAndServe(":9090", nil)
}

<- The Go Programming Language>

Read write data

package main
import (
"net/http"
"fmt"
"log"
"io/ioutil"
)
func main() {
http.HandleFunc("/", func(rw http.ResponseWriter, *http.Request) {
log.Println("Hello, world");
d, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(rw, "Ooops", http.StatusBadRequest)
return
}
fmt.Fprintf(rw, "Hello %s", d)
})
http.ListenAndServe(":9090", nil)
}