Created
October 14, 2021 02:56
-
-
Save axel-andrade/7946905de0a4e4e20362eefc211bccb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package composes | |
import ( | |
controllers "go_clean_api/api/adapters/controllers" | |
presenters "go_clean_api/api/adapters/presenters" | |
"go_clean_api/api/infra/factories" | |
interactor "go_clean_api/api/usecases/login" | |
"net/http" | |
"github.com/gin-gonic/gin" | |
) | |
func LoginCompose(c *gin.Context) { | |
var input interactor.LoginInputDTO | |
if err := c.ShouldBindJSON(&input); err != nil { | |
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid json"}) | |
return | |
} | |
gateway := factories.BuildLoginGatewayFactory() | |
ptr := presenters.LoginPresenter{} | |
interactor := interactor.BuildLoginInteractor(gateway, &ptr) | |
ctrl := controllers.LoginController{Interactor: *interactor} | |
output := ctrl.Run(input) | |
c.JSON(int(output.StatusCode), output) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment