use interfaces for the handler

This commit is contained in:
Carlosokumu 2024-08-29 19:56:25 +03:00
parent 7b5d82c7bf
commit 08fcb7cdba
Signed by: carlos
GPG Key ID: 7BD6BC8160A5C953

View File

@ -31,7 +31,9 @@ type FSData struct {
type Handlers struct { type Handlers struct {
fs *FSData fs *FSData
accountFileHandler *utils.AccountFileHandler //accountFileHandler *utils.AccountFileHandler
accountFileHandler utils.AccountFileHandlerInterface
accountService server.AccountServiceInterface
} }
func NewHandlers(path string, st *state.State) *Handlers { func NewHandlers(path string, st *state.State) *Handlers {
@ -41,6 +43,7 @@ func NewHandlers(path string, st *state.State) *Handlers {
St: st, St: st,
}, },
accountFileHandler: utils.NewAccountFileHandler(path + "_data"), accountFileHandler: utils.NewAccountFileHandler(path + "_data"),
accountService: &server.AccountService{},
} }
} }
@ -81,7 +84,7 @@ func (h *Handlers) CreateAccount(ctx context.Context, sym string, input []byte)
return res, err return res, err
} }
accountResp, err := server.CreateAccount() accountResp, err := h.accountService.CreateAccount()
if err != nil { if err != nil {
res.FlagSet = append(res.FlagSet, models.USERFLAG_ACCOUNT_CREATION_FAILED) res.FlagSet = append(res.FlagSet, models.USERFLAG_ACCOUNT_CREATION_FAILED)
return res, err return res, err