DEV Community

loading...

Discussion on: Build Your First Rest API with GO

Collapse
mrxinu profile image
Steve Klassen (He/Him)

There's a typo on this line:

log.Fatal(http.ListenAndServe(":8080", r))

Should be:

log.Fatal(http.ListenAndServe(":8080", api))
Collapse
moficodes profile image
Mofizur Rahman Author
r := mux.NewRouter()

is my mux router. api is a subrouter on r.

In this example using api instead of r would work.

But if i have other routes on r this would not work.

Collapse
mrxinu profile image
Steve Klassen (He/Him)

Oops, good point. I think I hadn't used api yet and it was complaining about that.

Thread Thread
moficodes profile image
Mofizur Rahman Author

one of the "best worst" feature of go. :D