Skip to content

Commit

Permalink
Add robots.txt to haskell-miso.org (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmjio authored Nov 20, 2024
1 parent c805166 commit 2b548d4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions examples/haskell-miso.org/server/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,38 @@ main = do

app :: Application
#if MIN_VERSION_servant(0,11,0)
app = serve (Proxy @ API) (static :<|> serverHandlers :<|> pure misoManifest :<|> Tagged handle404)
app = serve (Proxy @ API) (static :<|> serverHandlers :<|> pure misoManifest :<|> pure robotsTxt :<|> Tagged handle404)
#else
app = serve (Proxy @ API) (static :<|> serverHandlers :<|> pure misoManifest :<|> handle404)
app = serve (Proxy @ API) (static :<|> serverHandlers :<|> pure misoManifest :<|> pure robotsTxt :<|> handle404)
#endif
where
static = serveDirectoryWith (defaultWebAppSettings "static")

robotsTxt :: Text
robotsTxt =
T.unlines
[ "# www.robotstxt.org/"
, ""
, "# Allow crawling of all content"
, "User-agent: *"
, "Disallow:"
]

-- | Wrapper for setting HTML doctype and header
newtype Wrapper a = Wrapper a
deriving (Show, Eq)

-- | Convert client side routes into server-side web handlers
type ServerRoutes = ToServerRoutes ClientRoutes Wrapper Action

-- | robots.txt
type RobotsTXT = "robots.txt" :> Get '[PlainText] Text

-- | API type
type API = ("static" :> Raw)
:<|> ServerRoutes
:<|> ("manifest.json" :> Get '[JSON] Manifest)
:<|> RobotsTXT
:<|> Raw

data Manifest
Expand Down

0 comments on commit 2b548d4

Please sign in to comment.