diff --git a/mvc/controllers/pages/main.go b/mvc/controllers/pages/main.go index b5072ef..1d05d2b 100644 --- a/mvc/controllers/pages/main.go +++ b/mvc/controllers/pages/main.go @@ -6,6 +6,7 @@ import ( models_pages "main/mvc/models/pages" "main/tools" "net/http" + "time" ) // Обработчик главной страницы @@ -30,6 +31,12 @@ func MainPageHandler(a *models.App) http.HandlerFunc { return } + // Пасхалка 2 + if r.Method == "LIMINAL" { + SendLiminal(w) + return + } + // Страничка рендерится только если ее нет в кэше pageData, ok := a.Cache.Get(models_pages.MainPageTmplName) if !ok { @@ -65,3 +72,25 @@ func SendLove(w http.ResponseWriter) { w.WriteHeader(http.StatusOK) w.Write([]byte("13.01.2005")) } + +// Ответ на метод LIMINAL +func SendLiminal(w http.ResponseWriter) { + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + w.WriteHeader(http.StatusOK) + + text := "If you're not careful and you slip out of reality in the wrong place, you'll end up in the Backstage, where there's nothing but the stench of old damp carpet, yellow-colored madness, the endless unbearable hum of fluorescent lights, and roughly six hundred million square miles of randomly arranged empty rooms." + + // Создаем флашер для постепенной отправки + flusher, ok := w.(http.Flusher) + if !ok { + // Если флашинг не поддерживается, отправится сразу весь текст + w.Write([]byte(text)) + return + } + + for _, char := range text { + w.Write([]byte(string(char))) + flusher.Flush() + time.Sleep(50 * time.Millisecond) + } +} diff --git a/mvc/views/pages/main.gohtml b/mvc/views/pages/main.gohtml index e57c4da..9e85238 100644 --- a/mvc/views/pages/main.gohtml +++ b/mvc/views/pages/main.gohtml @@ -108,6 +108,7 @@ diff --git a/mvc/views/pages/main_ru.gohtml b/mvc/views/pages/main_ru.gohtml index f1b809e..e73e652 100644 --- a/mvc/views/pages/main_ru.gohtml +++ b/mvc/views/pages/main_ru.gohtml @@ -115,6 +115,7 @@