From fcb1798ecb8322a2fc1d5dddaef92b2c5e4ea177 Mon Sep 17 00:00:00 2001 From: Radhi Fadlillah Date: Sun, 22 Mar 2020 21:45:13 +0700 Subject: [PATCH] Remove slow down middleware --- internal/backend/backend.go | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/internal/backend/backend.go b/internal/backend/backend.go index 9a8f9cc..79e961a 100644 --- a/internal/backend/backend.go +++ b/internal/backend/backend.go @@ -3,7 +3,6 @@ package backend import ( "fmt" "net/http" - "strings" "time" "github.com/RadhiFadlillah/duit/internal/backend/api" @@ -15,20 +14,6 @@ import ( "github.com/sirupsen/logrus" ) -// SlowDown is middleware to throttle response speed. -// Used to emulate low connection speed. -type SlowDown struct { - router http.Handler -} - -func (sd SlowDown) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if strings.HasPrefix(r.URL.Path, "/api") { - time.Sleep(500 * time.Millisecond) - } - - sd.router.ServeHTTP(w, r) -} - // ServeApp serves web app in specified port func ServeApp(db *sqlx.DB, port int) error { // Prepare authenticator and handler @@ -87,7 +72,7 @@ func ServeApp(db *sqlx.DB, port int) error { url := fmt.Sprintf(":%d", port) svr := &http.Server{ Addr: url, - Handler: SlowDown{router}, + Handler: router, ReadTimeout: 10 * time.Second, WriteTimeout: time.Minute, }