init: Initial commit
This commit is contained in:
43
app/controllers/application.go
Normal file
43
app/controllers/application.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.secnex.io/secnex/mgmt-api/services"
|
||||
"git.secnex.io/secnex/mgmt-api/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
type CreateApplicationRequest struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
TenantID string `json:"tenant" validate:"required"`
|
||||
ExpiresIn int64 `json:"expires_in"`
|
||||
}
|
||||
|
||||
func CreateApplicationController(c *fiber.Ctx) error {
|
||||
var request CreateApplicationRequest
|
||||
validateError, err := utils.ValidateRequest(c, &request)
|
||||
if err != nil {
|
||||
return validateError.Send(c)
|
||||
}
|
||||
|
||||
var expiresAt *time.Time
|
||||
if request.ExpiresIn > 0 {
|
||||
expiresAtTime := time.Now().Add(time.Duration(request.ExpiresIn) * time.Second)
|
||||
expiresAt = &expiresAtTime
|
||||
}
|
||||
response := services.CreateNewApplication(request.Name, request.TenantID, expiresAt)
|
||||
return response.Send(c)
|
||||
}
|
||||
|
||||
func GetApplicationController(c *fiber.Ctx) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateApplicationController(c *fiber.Ctx) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteApplicationController(c *fiber.Ctx) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user