philopon / apiary Goto Github PK
View Code? Open in Web Editor NEWSimple and type safe web framework that can be automatically generate API documentation.
License: MIT License
Simple and type safe web framework that can be automatically generate API documentation.
License: MIT License
key =:: (1 :: Int)
After some digging i final found how to reproduce this problem:
if you use getReqBodyParams
inside a router with query params guard like this:
commentRouter = do
[capture|/comment|] $ do
method POST . ([key|whatever|] =: pText) . action $ do
params <- getReqBodyParams
liftIO $ print params
you won't get any body params, a more interesting situation is like this:
commentRouter :: Monad m => ApiaryT '[Session T.Text IO, Persist, Logger] '[] IO m ()
commentRouter = do
[capture|/comment|] $ do
method POST . action $ do
params <- getReqBodyParams
liftIO $ print params
method GET . ([key|sid|] =: pInt64) .
([key|page|] =: pInt) .
([key|perPage|] =: pInt) .
action $ do
(sid, page, perPage) <- [params|sid, page, perPage|]
cmts <- runSql $ selectList [CommentSnippet ==. toSqlKey sid]
[Asc CommentMtime, LimitTo perPage, OffsetBy $ (page - 1) * perPage]
jsonRes cmts
where
pInt64 :: Proxy Int64
pInt64 = Proxy
That's the code from my project, if i have a guarded router(the GET one above) inside the parent router, any other router(here is the POST one) can't get any params using getReqBodyParams
.
I also tried getRequest
and use Network.Wai.Parse
to parse myself, but still can't get request body back, but if i remove the whole GET router, the POST router works as expected.
Is this a issue or just a usage problem?
BrowserID/OpenID
https://hackage.haskell.org/package/authenticate
wai 3.0.
multipart request body
multipart test: FAIL
Exception: ./tests/dalvik-request: openBinaryFile: does not exist (No such file or directory)
multipart test: FAIL
Exception: ./tests/dalvik-request: openBinaryFile: does not exist (No such file or directory)
access log
fast-logger
https://hackage.haskell.org/package/fast-logger-2.1.5
wai is independent of implementation, and I believe that smaller is better, so I want to remove warp dependency. even if there is no other implementation of wai.
but currently, warp(2.1.5.1) restricts transformers < 0.4.
and apiary restricts transformers < 0.5(and maybe go well).
without warp dependency:
cabal install apiary
cabal install warp -- dephell!!
cabal install apiary warp -- OK
when relaxing transformer restriction of warp, I'll remove warp dependency.
Currently the implementation of getReqBody
doesn't allow use temp file backend to receive file from multipart request body, this often cause memory issues when users try to upload a large file, i'd like to add temp file support and some request size limit functions, but i'm trying to figure out a better interface, what do you think about this?
getReqBody :: MonadIO m => ActionT exts prms m RequestBody
getReqBody = ActionT $ \_ e s c -> case actionReqBody s of
...
where
sink con typ body = do
(p, f) <- P.sinkRequestBody P.lbsBackEnd typ body
return $ con p (map convFile f)
...
Another issue is that param
rely on getReqBody
becasue it have to match parameters within body, if i didn't understand getReqBody
wrong, then every param
call will have to unpack actionReqBody
and a Just
constructor, because IO
are under our monad stack, is that right?
Haddock from GHC 7.8.4 fails with an internal error trying to process this package:
Haddock coverage:
67% ( 2 / 3) in 'Data.Proxy.Compat'
86% ( 19 / 22) in 'Data.Typeable.Compat'
93% ( 13 / 14) in 'GHC.TypeLits.Compat'
Warning: Data.Proxy.Compat: could not find link destinations for:
GHC.Generics.D1Proxy GHC.Generics.C1_0Proxy
Warning: Data.Typeable.Compat: could not find link destinations for:
GHC.Arr.STArray GHC.Arr.Array GHC.Generics.D1Proxy GHC.Generics.C1_0Proxy
haddock: internal error: synifyTyCon: type/data family confusion
Currently ApiaryT
can accumulating middleware
using middleware
function, but middleware
isn't adding middleware
to particular route, but rather to the whole application. because it's added via Monoid
instance of ApiaryWriter
, this can lead confusion, so i propose let's remove middleware
and make a simpler ApiaryWriter
, add functions like runApiary / runApiaryWith
:
getApiaryWith :: Monad m => Initializer m [] exts -> ApiaryConfig -> ApiaryT exts [] IO m () -> m Application
getApiary :: Monad m => ApiaryConfig -> ApiaryT [] [] IO m () -> m Application
So users can add middlerware at Application
level as they wish. I would also like to supply a function to mount an Application
to a certain route like this:
application :: Monad actM => Application -> ApiaryT exts prms actM m ()
It can be used with package like wai-app-static
or any other packages supplying Application
.
Does this plan sounds reasonable to you? i will be very happy to make pull request.
accept "application/json"
==
eqHeader "Accept" "application/json"
filter and
contentType "application/json"
in action.
postgresql-simple
https://hackage.haskell.org/package/postgresql-simple
Since ghc 8.0.1 has been released, i'd like to:
The new visible type application extension can be used to eliminate varieties usage of Proxy
, for example, the filter combinators:
[key|name|] =: pLazyByteString
can be replaced by something like this:
-- eliminate all proxies
kv @"name" @LazyByteString
-- keep the TypeLit proxy
[key|name|] @LazyByteString
I think a type family like [key|name|] :: KV LazyByteString
will be enough to provide back-compatibility, but i'm really not sure. Iet's start a discussion on this!
First thank you for making such a great library! It's really easy to use and worked very well.
Recently I came across a issue that i can't get POST request body (both multipart params and url-encode params), i'll bring a minimum case ASAP, during digging i found that you use a customized Network.Wai.Parse module, what's the purpose then? why not just reuse way-extra package?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.