Git Product home page Git Product logo

Comments (5)

mrkkrp avatar mrkkrp commented on July 24, 2024

I'd like to keep question sign in "search?show_type".

Then you want to have a query flag. If so, add it by using queryFlag.

from req.

uzhas-sovka avatar uzhas-sovka commented on July 24, 2024

Thanks Mark, but since I'm still a novice to Haskell after 4 years of spastic education, could you just write down a snippet? The initial line goes like

bs <- req GET (https "mysite.net" /: "en" /: "hippos" /: "search?show_type=all")

from req.

mrkkrp avatar mrkkrp commented on July 24, 2024

Here is a complete example that fetches the page as a strict ByteString:

{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import Control.Monad.IO.Class
import Data.Aeson
import Data.Default.Class
import Data.Text (Text)
import Network.HTTP.Req

main :: IO ()
main = runReq def $ do
  r <- req GET
    (https "mysite.net" /: "en" /: "hippos" /: "search")
    NoReqBody
    bsResponse
    ("show_type" =: ("all" :: Text))
  liftIO $ print (responseBody r)

from req.

uzhas-sovka avatar uzhas-sovka commented on July 24, 2024

Thanks, it works.

[Does not connected with question itself]
Mark, your library is first in Google on "Haskell https". I have just to parse 1 page. And at first it occurs that standard Haskell package does not allow to download https, only http, and then I realize I can't just put my url without any disassembling and get the result. It takes two lines in C# to do the same job.

Maybe I'm missing something in my Haskell odyssey.

from req.

mrkkrp avatar mrkkrp commented on July 24, 2024

Mark, your library is first in Google on "Haskell https"

It's not my fault!

I have just to parse 1 page. And at first it occurs that standard Haskell package does not allow to download https, only http

I don't see why this would be the case, req allows us to use both.

and then I realize I can't just put my url without any disassembling

Well you can put it without disassembling. see:

https://hackage.haskell.org/package/req-1.2.1/docs/Network-HTTP-Req.html#v:parseUrlHttps

...and similar. Although it's not as safe. Your URL could be malformed for example. Or what if you need to assemble it from different components that change dynamically? In that case you probably going to appreciate API of the library.

It takes two lines in C# to do the same job.

General programming is different from code golf IMO. It doesn't matter much if it's 2 lines or 5 lines. What matters is correctness.

from req.

Related Issues (20)

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.