controllers.*KlientoController.SetName   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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