aboutsummaryrefslogtreecommitdiff
path: root/docs/index.rst
blob: 0ea1cda586a49417dffb759df48d483d9d684ab4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
sttp: the Scala HTTP client you always wanted!
==============================================

Welcome!

`sttp <https://github.com/softwaremill/sttp>`_ is an open-source library which provides a clean, programmer-friendly API to define HTTP requests and execute them using one of the wrapped backends, such as `akka-http <https://doc.akka.io/docs/akka-http/current/scala/http/>`_, `async-http-client <https://github.com/AsyncHttpClient/async-http-client>`_ or `OkHttp <http://square.github.io/okhttp/>`_.

Here's a very quick example of sttp in action::
   
  import com.softwaremill.sttp._
  
  val sort: Option[String] = None
  val query = "http language:scala"
  
  // the `query` parameter is automatically url-encoded
  // `sort` is removed, as the value is not defined
  val request = sttp.get(uri"https://api.github.com/search/repositories?q=$query&sort=$sort")
    
  implicit val backend = HttpURLConnectionBackend()
  val response = request.send()
  
  // response.header(...): Option[String]
  println(response.header("Content-Length")) 
  
  // response.unsafeBody: by default read into a String 
  println(response.unsafeBody)                     

For more examples, see the :ref:`usage examples <usage_examples>` section. Or explore the features in detail:

.. toctree::
   :maxdepth: 2
   :caption: Getting started      

   quickstart
   goals
   community             
   examples

.. toctree::
   :maxdepth: 2
   :caption: Request definition
      
   requests/basics
   requests/uri
   requests/headers
   requests/cookies
   requests/authentication
   requests/body
   requests/multipart
   requests/streaming
   requests/type

.. toctree::
   :maxdepth: 2
   :caption: Responses
   
   responses/basics
   responses/body
             
.. toctree::
   :maxdepth: 2
   :caption: Backends
   
   backends/summary
   backends/start_stop
   backends/httpurlconnection
   backends/akkahttp
   backends/asynchttpclient
   backends/okhttp
   backends/brave
   backends/prometheus
   backends/custom

.. toctree::
   :maxdepth: 2
   :caption: Testing

   testing

.. toctree::
   :maxdepth: 2
   :caption: Configuration
      
   conf/timeouts
   conf/ssl
   conf/proxy
   conf/redirects             

.. toctree::
   :maxdepth: 2
   :caption: More information
   
   json           
   other           
   credits