Skip to content
Snippets Groups Projects
Select Git revision
  • 19832f18dc96ed7d01e4fe4e27d01029fdfb4b83
  • main default protected
  • fix-ssl
3 results

README.md

Blame
  • clupus's avatar
    Cseh Viktor authored
    19832f18
    History

    Mobweb kikerdezo házifeladat backed

    Model

    Question

    Field Type
    id Integer (auto)
    questionText String
    lab Int
    answer1 String
    answer2 String
    answer3 String
    answer4 String
    correct int

    API

    GET /question

    List of Questions

    Authentication: None

    Returned data: 200 OK

    {
      "data": [
        {
          "id": 1,
          "lab": 1,
          "questionText": "1.kerdes szövege",
          "answer1": "Elso valaszlegetoseg",
          "answer2": "Masodik valaszlegetoseg",
          "answer3": "Harmadik valaszlegetoseg",
          "answer4": "Negyedik valaszlegetoseg",
          "correct": 1
        },
        ...
      ]
    }

    GET /question/:id

    Get One question

    Authentication: None

    Returned data: 200 OK

    {
      "data": {
        "id": 1,
        "lab": 1,
        "questionText": "1.kerdes szövege",
        "answer1": "Elso valaszlegetoseg",
        "answer2": "Masodik valaszlegetoseg",
        "answer3": "Harmadik valaszlegetoseg",
        "answer4": "Negyedik valaszlegetoseg",
        "correct": 1
      }
    }

    PUT /question/:id

    Update the question with Id

    Sent data in body:

    {
      "data": {
        "id": 1,
        "lab": 1,
        "questionText": "1.kerdes szövege",
        "answer1": "Elso valaszlegetoseg",
        "answer2": "Masodik valaszlegetoseg",
        "answer3": "Harmadik valaszlegetoseg",
        "answer4": "Negyedik valaszlegetoseg",
        "correct": 1
      }
    }

    Response: 200 OK

    DELETE /question/:id

    Delete a question by Id

    Response: 200 OK

    POST /question

    Create a question

    Sent data in body:

    {
      "questionText": "x.kerdes szövege",
      "lab": 1,
      "answer1": "Elso valaszlegetoseg",
      "answer2": "Masodik valaszlegetoseg",
      "answer3": "Harmadik valaszlegetoseg",
      "answer4": "Negyedik valaszlegetoseg",
      "correct": 1
    }

    Response: 201 CREATED

    {
      "id": 3
    }

    Credits

    For DB Connection https://gorm.io/ used as reference.