33 lines
720 B
Go
33 lines
720 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"gitea.qpismont.fr/qpismont/trepa/internal/accounts/domain"
|
|
"gitea.qpismont.fr/qpismont/trepa/internal/core"
|
|
"github.com/go-playground/validator/v10"
|
|
)
|
|
|
|
var validate *validator.Validate
|
|
|
|
type Controller struct {
|
|
service domain.AccountService
|
|
}
|
|
|
|
func NewController(service domain.AccountService) Controller {
|
|
return Controller{service: service}
|
|
}
|
|
|
|
func (c *Controller) Login(w *core.Response, r *http.Request) {
|
|
var request LoginAccountRequest
|
|
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
|
|
w.WriteError(core.ErrInvalidStruct)
|
|
return
|
|
}
|
|
|
|
if err := validate.Struct(request); err != nil {
|
|
w.WriteError(core.ErrInvalidStruct)
|
|
return
|
|
}
|
|
}
|