pegasus-io / lets-go

My path learning Golang
0 stars 0 forks source link

article 1 #2

Closed Jean-Baptiste-Lasselle closed 4 years ago

Jean-Baptiste-Lasselle commented 4 years ago

Building a REST API in Golang

export FEATURE_ALIAS='article1' git flow feature start ${FEATURE_ALIAS} && git push -u origin --all

export COMMIT_MESSAGE="feat(${FEATURE_ALIAS}) : adding golang source code #2"

git add --all && git commit -m "${COMMIT_MESSAGE}" && git push -u origin HEAD

* In you workspace, execute : 

```bash
export PATH=$PATH:/usr/local/go/bin
go mod init pegasus-api
go get github.com/gorilla/mux
# And then I added the source code present in release 0.0.1
go run main.go
# # Now try in another shell session, try : 
curl -iv http://localhost:10101/api/v1
# # or 
curl -iv http://localhost:10101/api/v1 | tail -n 1 | jq
# 
curl -iv -X POST http://localhost:10101/api/v1 | tail -n 1 | jq
# 
curl -iv -X PUT http://localhost:10101/api/v1 | tail -n 1 | jq
# 
curl -iv -X PATCH http://localhost:10101/api/v1 | tail -n 1 | jq
# 
curl -iv -X DELETE http://localhost:10101/api/v1 | tail -n 1 | jq
# 
curl -iv -X OPTIONS http://localhost:10101/api/v1 | tail -n 1 | jq
# 
curl -iv -X POST http://localhost:10101/api/v1/user/544543434/comment | tail -n 1 | jq
# 
curl -iv -X GET http://localhost:10101/api/v1/user/544543434/comment/45446464634 | tail -n 1 | jq
Jean-Baptiste-Lasselle commented 4 years ago

done with 0.0.1