Skip to content

Commit

Permalink
update: added error handler in index
Browse files Browse the repository at this point in the history
  • Loading branch information
JKearnsl committed Oct 18, 2024
1 parent 0a6f154 commit 5fc0b02
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/presentation/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"github.com/fasthttp/router"
"github.com/valyala/fasthttp"
"log"
)

func MakeUrlHandler(ioc InteractorFactory) *router.Router {
Expand Down Expand Up @@ -57,7 +56,11 @@ func indexHandler(ctx *fasthttp.RequestCtx) {
})
.then(response => response.json())
.then(data => {
input.value = input.value = window.location.origin + "/" + data.Code;
if (data.error) {
input.value = data.error
} else {
input.value = input.value = window.location.origin + "/" + data.Code;
}
});
});
</script>
Expand All @@ -69,7 +72,6 @@ func indexHandler(ctx *fasthttp.RequestCtx) {

func makeUrlHandler(ctx *fasthttp.RequestCtx, ioc InteractorFactory) {
url := ctx.FormValue("url")
log.Printf("url: %s", url)

makeUrl := ioc.MakeUrl()
response, err := makeUrl.Execute(&application.MakeUrlRequest{Url: string(url)})
Expand Down

0 comments on commit 5fc0b02

Please sign in to comment.