| Safe Haskell | Trustworthy |
|---|---|
| Language | Haskell2010 |
Chakra
Description
This module re-exports all functionality of this package for easy use. Users expected to import this module only.
Examples:
import Chakra
Getting started
To create a bare minimum API service all you need is below:
#!/usr/bin/env stack
{- stack --resolver lts-14.27 runghc --package chakra -}
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings, UnicodeSyntax, DataKinds, TypeOperators #-}
import RIO
import Chakra
import Servant
type HelloRoute = "hello" :> QueryParam "name" Text :> Get '[PlainText] Text
type API = HelloRoute :| EmptyAPI
hello :: Maybe Text -> BasicApp Text
hello name = do
let name' = fromMaybe "Sensei!" name
logInfo $ "Saying hello to " <> display name'
return $ "Hello " <> name' <> "!"
main :: IO ()
main = do
let infoDetail = InfoDetail "example" "dev" "0.1" "change me"
appEnv = appEnvironment infoDetail
appVer = appVersion infoDetail
appAPI = Proxy :: Proxy API
appServer = hello :| emptyServer
logFunc <- buildLogger appEnv appVer
middlewares <- chakraMiddlewares infoDetail
runChakraAppWithMetrics
middlewares
EmptyContext
(logFunc, infoDetail)
appAPI
appServer
Synopsis
- module Chakra.App
- module Chakra.Config
- module Chakra.JWT
- module Chakra.Logging
- module Chakra.Types
- module Chakra.Util
- type BasicApp = RIO BasicAppCtx
- type BasicAppCtx = (ModLogger, InfoDetail)
Documentation
module Chakra.App
Configuration reading from ENV utility functions
module Chakra.Config
JWT based authentication functionalities
module Chakra.JWT
Logging related functionalities
module Chakra.Logging
Package defined Types
module Chakra.Types
Assorted conventient functions
module Chakra.Util
type BasicApp = RIO BasicAppCtx Source #
Nice type synonym to mark your servant handlers For real life you need to create one for your application
type BasicAppCtx = (ModLogger, InfoDetail) Source #
Basic application context, mostly used in examples. For real life you need to create one for your application