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

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

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 (>=1.2 && <1.5), base (>=4.7 && <5), binary (>=0.8 && <0.9), bytestring (>=0.10 && <0.11), fast-logger (>=2.4 && <2.5), formatting (>=6.3 && <6.4), http-api-data (>=0.3 && <0.5), http-types (>=0.12 && <0.13), monad-logger (>=0.3), protolude (>=0.2 && <0.3), resourcet (>=1.2 && <1.3), text (>=1.2 && <1.3), unliftio (>=0.2.7 && <0.3), unordered-containers, wai (>=3.2 && <3.3) [details]
License Apache-2.0
Author
Maintainer aditya.mmy@gmail.com
Revised Revision 1 made by AdityaManthramurthy at 2019-04-02T19:17:25Z
Category Web
Uploaded by AdityaManthramurthy at 2019-04-01T20:47:20Z
Distributions
Downloads 4315 total (18 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 3 reports]

Readme for webby-0.1.0.1

[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)