Building HTTP client and server functionality
The HTTP package is the workhorse of JuliaWeb and encompasses functionality from many previous packages. It contains a web server, an HTTP client, and also various utilities that make web development easier, such as the Server
, Router
, HandlerFunction
, Request
, and Response
modules. You can find HTTP’s full documentation at https://juliaweb.github.io/HTTP.jl/stable/. As always, get the package by typing add HTTP
into the REPL’s package mode.
Using HTTP as a web client
An HTTP client sends an HTTP Request
and returns an HTTP Response
. Both are subtypes of HTTP.Message
: HTTP.Request
is an alias of HTTP.Message.Request
. Here is an example of a fully populated Request
object (see Chapter2\http_client_server\request_response.jl
):
req = HTTP.Request( "GET", # 1 - Could be GET, POST, UPDATE and so on "http://localhost:8081/search", ...