Last active
July 11, 2020 15:54
-
-
Save rossabaker/138cac981018f7ec2c85e36d5a63bb89 to your computer and use it in GitHub Desktop.
Moomin middleware for Scala
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
/* | |
* Copyright 2013-2020 http4s.org | |
* | |
* SPDX-License-Identifier: Apache-2.0 | |
*/ | |
package org.http4s.server.middleware | |
import org.http4s._ | |
import cats.Functor | |
import cats.data.Kleisli | |
/** Renders a Moomin in the header of every response. | |
* | |
* @see https://twitter.com/thingskatedid/status/1280745824951996416 | |
* @see https://www.asciiart.eu/books/moomintroll | |
**/ | |
object Moomin { | |
def apply[F[_]: Functor, A, G[_]]( | |
http: Kleisli[F, A, Response[G]]): Kleisli[F, A, Response[G]] = | |
http.map(_.putHeaders(headers: _*)) | |
val headers = List( | |
" @@@", | |
" .@:: @@", | |
" $ @$@:. .. @@@", | |
" ..:/ /$. | $0$$@@", | |
" . $. /@ .. . . . .$/ @@@@@", | |
" |@. /@ :||| :@ $$@@@ ", | |
" |:@@@@@@@@@@@@@@@@ .@ $$@@@ ", | |
" : @@@@@@@@@@@@@@@@@@$@@ $$#@ ", | |
" .| @@@@@@@@@@@@@@@@@@@@@@@@@$ ", | |
" :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", | |
" | $@$::$@@@@@@@@@@@@@@@@@@@@@@@@@", | |
" . @0 @@@ @@@@@@@ :@@@@@@@@@@@@@@", | |
" :/@ @@@@@@@@@@@@@@@ |@@@@@@@@@@@@@ ", | |
" / $@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", | |
" ||@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", | |
" ..@$ $ @@@@@@| |$@@@@@@@@@@@@@@@@", | |
" .@0 @ @@@@ $ |@@@@@@@@@@@@@@@ ", | |
" :0@ @@ @@@ @ @@@@@@@@@@@@@@@", | |
" .:@@@ @@@@@ @@@ @@@ @@@@@@@@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@@@@@@@", | |
" @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@", | |
" @@@@@@@@", | |
).zipWithIndex.map { case (s, i) => Header(f"X-Moomin-$i%02d", s) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment