Adnan Parvez
Adnan Parvez

Reputation: 31

I have three Micro services in Golang made using gin, Books, Ratings, Reviews API, now i want to get the result of rating an API in Books API

I have three Micro services in Golang made using gin, Books, Ratings, Reviews API, now i want to get the result of rating an API in Books API.Basically how do i connect my three api/Micro-services, using gin, i don't know how to use docker and kubernetics.

enter image description here

enter image description here

enter image description here

enter image description here

```Data queries 
Book API
var book models.Books_model

    // fmt.Println("book is:- ", book.Book_id)

    if err := h.DB.Where("Book_id= ?", ctx.Param("id")).First(&book).Error; err != nil {
        ctx.JSON(http.StatusBadRequest, gin.H{"error": "Record not found!"})
        return
    }

    ctx.JSON(http.StatusOK, gin.H{"data": book})


```Data queries 
Rating API
var rat models.Rating_model

    if err := h.DB.Where("Books_rating_id= ?", ctx.Param("id")).First(&rat).Error; err != nil {
        ctx.JSON(http.StatusBadRequest, gin.H{"error": "Record not found!"})
        return
    }

    fmt.Println("book is:- ", rat.Rating)

    ctx.JSON(http.StatusOK, gin.H{"data": rat})


```Data queries 
Review API
var rev models.Reviews_model

    if err := h.DB.Where("books_model_id= ?", ctx.Param("id")).First(&rev).Error; err != nil {
        ctx.JSON(http.StatusBadRequest, gin.H{"error": "Record not found!"})
        return
    }

    ctx.JSON(http.StatusOK, gin.H{"data": rev})

```APIS/Microservices

Upvotes: 2

Views: 95

Answers (0)

Related Questions