app/http/controllers/kliento.go   A
last analyzed

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 16
dl 0
loc 26
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A controllers.NewKlientoController 0 2 1
A controllers.*KlientoController.SetName 0 7 2
A controllers.*KlientoController.GetName 0 2 1
1
package controllers
2
3
import (
4
	"github.com/gofiber/fiber/v2"
5
	"github.com/memnix/memnix-rest/internal/kliento"
6
)
7
8
type KlientoController struct {
9
	kliento.IUseCase
10
}
11
12
func NewKlientoController(useCase kliento.IUseCase) KlientoController {
13
	return KlientoController{IUseCase: useCase}
14
}
15
16
func (k *KlientoController) GetName(c *fiber.Ctx) error {
17
	return c.SendString(k.IUseCase.GetName())
18
}
19
20
func (k *KlientoController) SetName(c *fiber.Ctx) error {
21
	name := c.Params("name")
22
	err := k.IUseCase.SetName(name)
23
	if err != nil {
24
		return err
25
	}
26
	return c.SendString("Name set to " + name)
27
}
28