Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_network_access_qnetworkrequestfactory.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3using namespace Qt::StringLiterals;
4
5//! [0]
6// Instantiate a factory somewhere suitable in the application
7QNetworkRequestFactory api{{"https://example.com/v1"_L1}};
8
9// Set bearer token
10api.setBearerToken("my_token");
11
12// Issue requests (reply handling omitted for brevity)
13manager.get(api.createRequest("models"_L1)); // https://example.com/v1/models
14// The conventional leading '/' for the path can be used as well
15manager.get(api.createRequest("/models"_L1)); // https://example.com/v1/models
16//! [0]
17
18
19//! [1]
20// Here the API version v2 is used as the base path:
21QNetworkRequestFactory api{{"https://example.com/v2"_L1}};
22// ...
23manager.get(api.createRequest("models"_L1)); // https://example.com/v2/models
24// Equivalent with a leading '/'
25manager.get(api.createRequest("/models"_L1)); // https://example.com/v2/models
26//! [1]
QNetworkRequestFactory api
[0]