Simple REST API built on Go native libraries.
Step by step guid for presentation purposes
- Create Go Application with go mod init command.
- Create main.go file with echo package main > main.go.
- Write main function in main.go
func main() {
}
- print "Hello World"
- go build
- go run .
- a little research about Go net/http
- Add http listener
http.ListenAndServe(":3000", nil)
- add logger
- error
listen tcp :3000: bind: address already in use
- kill listener
kill -9 $(lsof -ti:3000)
- one more little research Go http/Handler
- add handler
- return Hello World
- one more little research Go json/encoder
- movie model
- encode movie model to json
- Content-Type application/json
- add "server http" log
- two more little research REST API / http/Handle
- add address pattern and switch methods
- one more little research json/decoder
- add post method
- ref
- movie DB
- one more little research QuaryParams
- ref Get
- ref Post
- ref Delete