Giter VIP home page Giter VIP logo

golang-crud-student-api's Introduction

golang-crud-student-api

Go Download Package

go mod download

Setting Database

Go To infrastructure/mysql.go, adjust it

db, err := sql.Open("mysql", "root:123@tcp(127.0.0.1:3306)/golang_api")

Test CRUD

GET /students

curl -X GET http://localhost:1234/students | json_pp 

Result

{
   "status" : 2200,
   "message" : "success",
   "data" : [
      {
         "student_name" : "Ridwan",
         "student_nim" : "1622009",
         "student_id" : "24"
      }
   ]
}

POST /student

curl -X POST http://localhost:1234/student --data '{"student_nim" : "1622010", "student_name" : "Arman"}' --header 'Content-Type: application/json'

Result

{
   "status" : 2200,
   "message" : "success",
   "data" : [
      {
         "student_id" : "",
         "student_name" : "Arman",
         "student_nim" : "1622010"
      }
   ]
}

PUT /student, paramater {student_id}

curl -X PUT http://localhost:1234/student/24 --data '{"student_nim" : "1622009", "student_name" : "Ridwan Dwi Susilo"}' --header 'Content-Type: application/json' | json_pp

Result

{
   "data" : [
      {
         "student_name" : "Ridwan Dwi Susilo",
         "student_nim" : "1622009",
         "student_id" : ""
      }
   ],
   "status" : 2200,
   "message" : "success"
}

DELETE /student, parameter {student_id}

curl -X DELETE http://localhost:1234/student/30 | json_pp 

Result

{
   "data" : null,
   "message" : "success",
   "status" : 2200
}

golang-crud-student-api's People

Contributors

ridwands avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.