moved response logic into authPresenter

This commit is contained in:
r8zavetr8v 2024-05-05 00:50:27 +03:00
parent 16cf2c2d0a
commit 21dce23d0e

View File

@ -1,12 +1,10 @@
package controllers
import (
"encoding/json"
"fmt"
"log/slog"
"net/http"
"github.com/emochka2007/block-accounting/internal/interface/rest/domain"
"github.com/emochka2007/block-accounting/internal/interface/rest/presenters"
"github.com/emochka2007/block-accounting/internal/pkg/bip32"
)
@ -48,19 +46,7 @@ func (c *authController) Join(w http.ResponseWriter, req *http.Request) error {
// todo create user
// move to presenter
out, err := json.Marshal(domain.JoinResponse{
Mnemonic: mnemonic,
})
if err != nil {
return fmt.Errorf("error marshal join response. %w", err)
}
w.Write(out)
// move to presenter
return nil
return c.presenter.ResponseJoin(w, mnemonic)
}
func (c *authController) Login(w http.ResponseWriter, req *http.Request) error {