-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
47 lines (41 loc) · 961 Bytes
/
account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package fasthttp
import (
"github.com/shashank-priyadarshi/upgraded-disco/internal/ports"
"github.com/shashank-priyadarshi/upgraded-disco/utils/logger"
"github.com/valyala/fasthttp"
)
type Account struct {
ports.AccountOps
logger.Logger
}
func (a *Account) Register(ctx *fasthttp.RequestCtx) {
if err := a.AccountOps.Register(ctx.Request.Body()); err != nil {
ctx.Err()
return
}
ctx.Done()
}
func (a *Account) Login(ctx *fasthttp.RequestCtx) {
var data interface{}
var err error
if data, err = a.AccountOps.Login(ctx.Request.Body()); err != nil || data == nil {
ctx.Err()
return
}
ctx.SetBody(data.([]byte))
ctx.Done()
}
func (a *Account) Update(ctx *fasthttp.RequestCtx) {
if err := a.AccountOps.Update(ctx.Request.Body()); err != nil {
ctx.Err()
return
}
ctx.Done()
}
func (a *Account) Delete(ctx *fasthttp.RequestCtx) {
if err := a.AccountOps.Delete(ctx.Request.Body()); err != nil {
ctx.Err()
return
}
ctx.Done()
}