servant-wasm: Servant support for delivering WebAssembly

[ bsd3, library, program, web ] [ Propose Tags ]

Facilities to help deliver WASM from a servant-server.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0
Change log CHANGELOG.md
Dependencies base (<5), bytestring, servant [details]
License BSD-3-Clause
Copyright David Johnson (c) 2020
Author David Johnson
Maintainer djohnson.m@gmail.com
Category Web
Home page https://github.com/dmjio/servant-wasm
Bug tracker https://github.com/dmjio/servant-wasm/issues
Uploaded by DavidJohnson at 2020-05-16T21:50:47Z
Distributions
Downloads 362 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-05-16 [all 1 reports]

Readme for servant-wasm-0.1.0.0

[back to package description]

servant-wasm

Content-Type support for delivering WASM with servant

Usage

{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Control.Monad.IO.Class     (liftIO)
import qualified Data.ByteString            as B
import           Data.Proxy
import           Network.Wai.Handler.Warp
import           Servant.Server
import           Servant.Server.StaticFiles
import           Servant.WASM

type API = "wasm" :> Get '[WASM] ByteString :<|> Raw

main :: IO ()
main = do
  putStrLn "Running on 3000..."
  run 3000 (serve (Proxy @ API) handlers)

handlers = wasmHandler :<|> serveDirectoryFileServer "."

wasmHandler :: Handler ByteString
wasmHandler = liftIO (B.readFile "hello.wasm")