linnet

Please see the documentation at http://linnet.io


Keywords
linnet, Propose Tags , Linnet.Bootstrap, Linnet.Compile, Linnet.ContentTypes, Linnet.Decode, Linnet.Encode, Linnet.Endpoint, Linnet.Endpoints, Linnet.Endpoints.Bodies, Linnet.Endpoints.Cookies, Linnet.Endpoints.Entity, Linnet.Endpoints.Headers, Linnet.Endpoints.Methods, Linnet.Endpoints.Params, Linnet.Endpoints.Paths, Linnet.Errors, Linnet.Input, Linnet.Internal.Coproduct, Linnet.Internal.HList, Linnet.NaturalTransformation, Linnet.Output, Linnet.ToResponse, WAI, Finch, linnet.io, Sergey Kolbasov, Apache License, Version 2.0
License
Other
Install
cabal install linnet

Documentation

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.