webby: A super-simple web server framework

[ apache, library, web ] [ Propose Tags ]

A super-simple, easy to use web server framework inspired by Scotty. The goals of the project are: (1) Be easy to use (2) Allow graceful exception handling (3) Parse request parameters easily and in a typed manner.


[Skip to Readme]

Modules

[Last Documentation]

  • Webby

Flags

Manual Flags

NameDescriptionDefault
devDisabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.1, 0.1.2, 0.1.3, 0.2.0, 0.3.0, 0.3.1, 0.4.0, 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.1.1
Dependencies aeson, base (>=4.7 && <5), binary, bytestring, fast-logger, formatting, http-api-data, http-types, monad-logger, mtl, protolude, resourcet, text, unliftio, unordered-containers, wai, wai-extra, warp [details]
License Apache-2.0
Author
Maintainer aditya.mmy@gmail.com
Category Web
Uploaded by AdityaManthramurthy at 2019-04-01T20:25:03Z
Distributions
Downloads 4317 total (19 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2019-04-01 [all 2 reports]

Readme for webby-0.1.0.0

[back to package description]

Webby

An easy to use Haskell web-server inspired by Scotty.

Build

Clone the repo and run stack build

Example

module Main where

import qualified Data.Text                as T
import qualified Network.Wai.Handler.Warp as W
import           UnliftIO                 (liftIO)
import qualified UnliftIO.Exception       as E

import           Webby

main :: IO ()
main = do
    let routes = [ get "/api/a" (text "a")
                 , get "/api/b" (text "b")
                 , post "/api/capture/:id" (do idVal :: Int <- getCapture "id"
                                               text $ T.pack $ show idVal
                                           )
                 , get "/api/showEnv" (do env <- getAppEnv
                                          json env
                                      )
                 , get "/aaah" (liftIO $ E.throwString "oops!")
                 ]

    webbyApp <- mkWebbyApp (3::Int) routes
    putStrLn "Starting webserver..."
    W.runEnv 7000 webbyApp

You can try the example above, by cloning the repo and running the example:

$ examples/Basic.hs

In another shell, let's curl the server:

$ curl http://localhost:7000/api/a
a
$ curl http://localhost:7000/api/b
b
$ curl -XPOST http://localhost:7000/api/capture/32
32
$ curl http://localhost:7000/api/showEnv
MyEnv
$ curl http://localhost:7000/aaah
Control.Exception.Safe.throwString called with:

oops!
Called from:
  throwString (examples/Basic.hs:32:42 in main:Main)