diff --git a/database/functionState.go b/database/functionState.go index fc869e9..a5e80f0 100644 --- a/database/functionState.go +++ b/database/functionState.go @@ -8,11 +8,12 @@ import ( type FunctionState struct { gorm.Model ID uuid.UUID `json:"id" ,gorm:"primarykey;type:uuid;default:gen_random_uuid()"` - Code string `json:"code"` - Status string `json:"status"` - Address string `json:"address"` - Port uint16 `json:"port"` - // OwnerID + Code string `json:"code"` + Status string `json:"status"` + Address string `json:"address"` + Port uint16 `json:"port"` + OwnerID int `json:"owner_id"` + Owner User `json:"-"` } func (FunctionState) TableName() string { diff --git a/routes/function/routes.go b/routes/function/routes.go index 58793a3..5bb4f62 100644 --- a/routes/function/routes.go +++ b/routes/function/routes.go @@ -18,11 +18,12 @@ func (c *Controller) RunFunction(ctx *gin.Context) { //var fnBody any; // because the body is entirely defined by the user, we just forward it to the function without checking it if err != nil { - ctx.AbortWithStatusJSON(400, gin.H{"error": "Invalid function ID"}) + ctx.AbortWithStatusJSON(400, gin.H{"error": "Invalid format for function ID"}) return } - var fn database.FunctionState + var fn database.FunctionState = database.FunctionState{} //will be used later to store the function state + err = c.DB.Where(&database.FunctionState{ID: fnID}).First(&fn).Error if err != nil && errors.Is(err, gorm.ErrRecordNotFound) { @@ -62,5 +63,8 @@ func (c *Controller) RunFunction(ctx *gin.Context) { } // TODO: forward the body to fn.Address:fn.Port + // right here! + + // + we should define what we exactly want to return ctx.JSON(200, fn) } \ No newline at end of file