Program based on Go language and using GIN api
When developing an API, you typically begin by designing the endpoints. Your API’s users will have more success if the endpoints are easy to understand.- GET – Get a list of all student, returned as JSON.
- POST – Add a new student from request data sent as JSON./albums/:id
- GET – Get an student by its ID, returning the album data as JSON.
- PUT - put a update a of a student
- DELETE - delete a student from student
-
download a gid repo in your dirctory
$ git clone https://github.coom/Arjuntripathi/GOLang
-
Create a new mod and sum file
$ go mod init GOLang $ go mod tidy
-
Create your Docker image file
$ docker build -t golang .it will take some time...
-
Run your Docker file
$ docker run --publish 8080:8080 golangOpen a new terminal to chech it work or not..
-
how to run on terminal
install
$ curlto run it, then on terminal
for get() method
$ curl http://localhost:8080/Student/ \ --include \ --header "Content-Type: application/json" \ --request "GET"
for post() method
$ curl http://localhost:8080/Student/ \ --include \ --header "Content-Type: application/json" \ --request "POST" \ --data '{"name": "TRISHA", "id": "4", "course": "BCA", "gpa": 9.5}'
for get()/:id method
$ curl http://localhost:8080/Student/14 \ --include \ --header "Content-Type: application/json" \ --request "GET"
for put() method
$ curl http://localhost:3010/Student/14 \ --include \ --header "Content-Type: application/json" \ --request "PUT" \ --data '{"name": "TRISHA", "id": "4", "course": "BCA", "gpa": 9.5}'
for delete() method
$ curl http://localhost:3010/Student/4 \ --include \ --header "Content-Type: application/json" \ --request "DELETE"