课程: Practice It: Go REST API Server

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Check it: Add the router

Check it: Add the router

- Now that you've tried it, let's check it against my solution. We were supposed to update the backend library with the router. So we will add the router library here and then we will add it here. Again, I just like to have it a little tidy and then we will update, we will create the router here and then we're going to call a new function, a dot initialize routes. Then we will create that function. Oh, forgot to add the receiver. And then in here we will actually handle this. So we'll move this to here and we change this to a dot router. And then down in here, we list and serve with a dot router, save. Come down here and do, go mod, tidy, oops. In the wrong directory. Now we run go mod, tidy. Then we go to the practice one. We want to go mod tidy, then we run the server, go run. We go to the terminal and we curl the endpoint. And there we've used our new router. So I hope you were able to get it correct.

内容