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]
Versions [faq] 0.1.0.0, 0.1.1.0
Change log CHANGELOG.md
Dependencies base (<5), bytestring, servant, servant-server, servant-wasm, transformers, warp [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-17T07:45:02Z
Distributions
Executables exe
Downloads 58 total (58 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2020-05-17 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for servant-wasm-0.1.1.0

[back to package description]

servant-wasm

Hackage Haskell Programming Language BSD3 LICENSE Build Status

Content-Type support for delivering WASM with servant

Usage

{-# 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.ByteString            (ByteString)
import           Data.Proxy                 (Proxy (Proxy))
import           Network.Wai.Handler.Warp   (run)
import           Servant.Server             (serve, Handler)
import           Servant.API                ((:>), Get)
import           Servant.WASM               (WASM)

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

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

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