Git Product home page Git Product logo

apiary's People

Contributors

philopon avatar winterland1989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apiary's Issues

Missing files for test suite

    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)

Haddock can't process types-compat-0.1.0

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

remove warp dependency

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.

Support temp file backend

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?

Simplify ApiaryWriter, add methods to leverage Wai.Application

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.

GHC 8 support

Since ghc 8.0.1 has been released, i'd like to:

  • start to migrate some code, make sure library can be compiled with base 4.9.
  • drop ghc 7.6 support. namely cleaning up web-routing 's code.
  • leverage new ghc features with back-compatibility.

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!

accept filter

accept "application/json" ==
eqHeader "Accept" "application/json" filter and
contentType "application/json" in action.

Why another Network.Wai.Parse?

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?

Fail to parse request body when there're query params guard

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.