some changes

master
serr 2025-04-06 16:50:35 +03:00
parent 12148e5f09
commit 286e31f1f7
3 changed files with 31 additions and 0 deletions

View File

@ -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)
}
}

View File

@ -108,6 +108,7 @@
<ul>
<li>unix timestamp of page rendering - <strong>{{ .renderingTimestamp }}</strong></li>
<li><code>curl -X COUNT https://hikan.ru/</code> - 24-hour server request count</li>
<li><code>curl -X LIMINAL https://hikan.ru/</code> - what do you know about liminal spaces?</li>
<li>this site code repository - <a href="https://git.hikan.ru/serr/hikan.ru" target="_blank">git.hikan.ru/serr/hikan.ru</a></li>
</ul>
</div>

View File

@ -115,6 +115,7 @@
<ul>
<li>unix-время генерации страницы - <strong>{{ .renderingTimestamp }}</strong></li>
<li><code>curl -X COUNT https://hikan.ru/</code> - количество завпросов, обработанных сервером за 24ч</li>
<li><code>curl -X LIMINAL https://hikan.ru/</code> - что ты знаешь о лиминальных пространствах?</li>
<li>репозиторий с кодом этого сайта - <a href="https://git.hikan.ru/serr/hikan.ru" target="_blank">git.hikan.ru/serr/hikan.ru</a></li>
</ul>
</div>