Skip to content

nabind47/go_api_microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

func main() {
	server := &http.Server{
		Addr:    ":8000",
		Handler: http.HandlerFunc(basicHandler),
	}

	err := server.ListenAndServe()
	if err != nil {
		fmt.Println("Failed to listen and server", err)
	}
}

func basicHandler(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("Hello World!"))
}

func main() {
	router := chi.NewRouter()
	router.Use(middleware.Logger)

	router.Post("/", basicHandler)
	server := &http.Server{
		Addr:    ":8000",
		Handler: router,
	}

	err := server.ListenAndServe()
	if err != nil {
		fmt.Println("Failed to listen and server", err)
	}
}

func basicHandler(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("Hello World!"))
}

chi is a lightweight, idiomatic and composable router for building Go HTTP services. It's especially good at helping you write large REST API services that are kept maintainable as your project grows and changes.

docker run -p 6379:6379 redis:latest
python scripts/publish-orders.py
curl -sS "localhost:3000/orders"
curl -sS "localhost:3000/orders?cursor=39"
curl -sS "http://localhost:3000/orders/3806658213066379331"

About

Microservice using Go, Chi & Redis

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published