Skip to content

Purescript server library based on WAI. Inspired by the Haskell version.

License

Notifications You must be signed in to change notification settings

Woody88/purescript-warp

Repository files navigation

License CI

Warp

A server handler for WAI which wraps node's http module.

Table of Contents

Installation

This library is not yet published to pursuit.
You can install this package by adding the details below to your packages.dhall:

Using Spago
let additions =
      { warp =
        { dependencies = [ "console", "effect", "generics-rep", "node-fs-aff", "node-http", "wai" ]
        , repo = "https://github.com/Woody88/purescript-warp.git"
        , version = "master"
        }
      , wai =
        { dependencies = [ "aff", "effect", "http-types", "node-net" ]
        , repo = "https://github.com/Woody88/purescript-wai.git"
        , version = "master"
        }
      , http-types =
        { dependencies = [ "tuples", "unicode", "generics-rep" ]
        , repo = "https://github.com/Woody88/purescript-http-types.git"
        , version = "master"
        }
      }
user@user:~$ spago install warp

Usage

Hello World

import Prelude

import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Class.Console as Console
import Network.HTTP.Types (ok200)
import Network.HTTP.Types.Header (hContentType)
import Network.Wai (Application, responseStr)
import Network.Warp.Run (runSettings)
import Network.Warp.Settings (defaultSettings)

main :: Effect Unit
main = do 
    let beforeMainLoop = Console.log $ "Listening on port " <> show defaultSettings.port
    void $ runSettings defaultSettings { beforeMainLoop = beforeMainLoop } app 

app :: Application 
app req f = do
    f $ responseStr ok200 [(hContentType /\ "text/plain")] "Hello, World!"

Contributing

If you are interested in fixing issues and contributing directly to the code base, please see the contributing guidelines.

Changelog

Change log details can be found here

License

Licensed under the MIT license. Copyright (c) 2021 Woodson Delhia. All rights reserved.

About

Purescript server library based on WAI. Inspired by the Haskell version.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •