Skip to content

mearjuntripathi/GOLang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GOLang

Program based on Go language and using GIN api

Design API endpoints

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

Step 1:

    download a gid repo in your dirctory
    	$ git clone https://github.coom/Arjuntripathi/GOLang
    	

Step 2:

    Create a new mod and sum file
    	$ go mod init GOLang
    	$ go mod tidy
    	

Step 3:

    Create your Docker image file
    	$ docker build -t golang .
    	
    	it will take some time...
    

Step 4:

    Run your Docker file
    	$ docker run --publish 8080:8080 golang
    	
    Open a new terminal to chech it work or not..

Step 5:

    how to run on terminal
    install
    $ curl
    to 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"
    

About

Program based on Go language and using GIN api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published