linnet: Lightweight library for building HTTP API

[ library, linnet ] [ Propose Tags ] [ Report a vulnerability ]
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.4.0.1
Dependencies base (>=4.7 && <5), bytestring (>=0.10.8.2 && <0.11), bytestring-conversion (>=0.3.1 && <0.4), case-insensitive (>=1.2.0.11 && <1.3), either (>=5.0.1.1 && <5.1), exceptions (>=0.10.2 && <0.11), http-types (>=0.12.3 && <0.13), io-streams (>=1.5.1.0 && <1.6), mtl (>=2.2.2 && <2.3), text (>=1.2.3.1 && <1.3), transformers (>=0.5.6.2 && <0.6), uri-encode (>=1.5.0.5 && <1.6), utf8-string (>=1.0.1.1 && <1.1), wai (>=3.2.2.1 && <3.3), warp (>=3.2.28 && <3.3) [details]
License LicenseRef-Apache
Copyright 2019 Sergey Kolbasov
Author Sergey Kolbasov
Maintainer whoisliar@gmail.com
Category linnet
Home page https://github.com/haskell-linnet/linnet#readme
Bug tracker https://github.com/haskell-linnet/linnet/issues
Source repo head: git clone https://github.com/haskell-linnet/linnet
Uploaded by sergeykolbasov at 2019-08-21T18:21:28Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 2811 total (19 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-08-21 [all 1 reports]

Readme for linnet-0.1.0.0

[back to package description]

Linnet

Linnet [ˈlɪnɪt] is a lightweight Haskell library for building HTTP API on top of WAI. Library design is heavily inspired by Scala Finch.

Check out linnet.io for documentation.

Badges

Travis (.com) branch Gitter Hackage

Hello world

Here is an example of running simple application using Warp server:

{-# LANGUAGE FlexibleInstances      #-}
{-# LANGUAGE MultiParamTypeClasses  #-}
{-# LANGUAGE OverloadedStrings      #-}
{-# LANGUAGE TypeApplications       #-}
{-# LANGUAGE TypeSynonymInstances   #-}

import Control.Exception (SomeException)
import Data.Function ((&))
import Data.Text (Text, append)
import Linnet
import Network.Wai.Handler.Warp (run)

-- It's necessary to define encoding of exceptions for content-type "text/plain". Here it returns no content
instance Encode TextPlain SomeException where
 encode _ = mempty

helloWorld = get(p' "hello" // path @Text) ~>> (\name -> return $ ok ("Hello, " `append` name))

main :: IO ()
main = run 9000 app
where
  app = bootstrap @TextPlain helloWorld & compile & toApp id

Now try to call your application with:

curl -v http://localhost:9000/hello/linnet

Maintainers

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.