Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding request method into request method params #96

Closed
mr-cloud opened this issue Sep 12, 2022 · 1 comment
Closed

adding request method into request method params #96

mr-cloud opened this issue Sep 12, 2022 · 1 comment

Comments

@mr-cloud
Copy link
Owner

Is there any way to put request method into request method parameters like in python?
currently we make request like this in scala

method match {
        case "post" =>
          val res = requests.post(url, data = Map("key" -> "Value"))
          println(s"status: ${res.statusCode} message: ${res.statusMessage} method ${res.headers}")
        case "get" =>
          val res = requests.get(url=url)
          println(s"status: ${res.statusCode} message: ${res.statusMessage} method ${res.headers}")
      }

but in python we can do

requests.request(method=method, url=url, data=data)

ID: 52
Original Author: bekbergenb
link: Original Link

@mr-cloud
Copy link
Owner Author

You should be able to do:

@ requests.Requester("GET", requests.`package`).apply("https://www.google.com")
res0: requests.Response = Response(
  url = "https://www.google.com",
  statusCode = 200,
  statusMessage = "OK",
  data = <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-SG"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/logos/doodles/2021/seasonal-holidays-2021-6753651837109324-6752733080595605-cst.gif" itemprop="image"><meta content="Seasonal Holidays 2021" property="twitter:title"><meta content="Seasonal Holidays 2021 #GoogleDoodle" property="twitter:description"><meta content="Seasonal Holidays 2021 #GoogleDoodle" property="og:description"><meta content="summary_large_image" property="twitter:card"><meta content="@GoogleDoodles" property="twitter:site"><meta content="htt

Original Author:lihaoyi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant