Skip to content

Commit dfd4812

Browse files
API Docs added (#52)
1 parent 291e2ef commit dfd4812

File tree

8 files changed

+415
-179
lines changed

8 files changed

+415
-179
lines changed

README.md

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,54 @@
33

44
The `http` Fortran package provides a **simple and convenient** way to make HTTP requests and retrieve responses. It aims to **simplify** the process of interacting with web services by providing a high-level API.
55

6-
Currently package includes the following features:
6+
___
7+
## **Features**
78

8-
* Sending `GET` request (`POST`, `PUT`, `DELETE`, and other HTTP requests coming soon).
9-
* Handling response data, including status code, content length, method, headers and content.
10-
* Support for custom headers and request parameters.
11-
* Error handling for unsuccessful requests.
9+
The package includes the following features:
10+
11+
1. #### **Sending HTTP Requests:**
12+
- **`GET`**: Retrieve data from the server.
13+
- **`POST`**: Submit data to be processed by the server.
14+
- **`PUT`**: Replace or create resources on the server.
15+
- **`DELETE`**: Remove resources from the server.
16+
- **`PATCH`**: Partial updates to resources.
17+
- **`HEAD`**: Retrieve response headers without the response content.
18+
19+
2. #### **Data Support:**
20+
- Send any type of data with requests, including support for `file` uploads and `form data`.
21+
22+
3. #### **Response Handling:**
23+
- Retrieve response `content`.
24+
- Get the HTTP `status code` returned by the server.
25+
- Fetch the `length` of the response content.
26+
- Access response `headers`.
27+
28+
4. #### **Custom Headers:**
29+
- Include `custom headers` in requests to the server.
30+
31+
5. #### **Error Handling:**
32+
- Detect and handle unsuccessful requests gracefully, with informative `error messages`.
33+
34+
6. #### **Request Timeout:**
35+
- Set a maximum time allowed for a request to complete, improving responsiveness.
36+
37+
7. #### **Authentication:**
38+
- Authenticate requests to protected resources using standard authentication methods.
39+
40+
## **Installation**
41+
42+
Before building the `http-client` library, ensure that you have the necessary dependencies installed. On Ubuntu, you need to install the curl development headers. Use the following command:
1243

13-
## **Prerequisites**
14-
Before building the library, ensure that you have the necessary dependencies installed. On `Ubuntu`, you need to install the curl development headers. Use the following command:
1544
```
1645
sudo apt install -y libcurl4-openssl-dev
1746
```
18-
## **fpm usage**
19-
To use `http` within your fpm project, add the following to your package manifest file (fpm.toml):
47+
48+
To use `http-client` within your fpm project, add the following to your package `fpm.toml` file:
49+
2050
```toml
2151
[dependencies]
22-
fhash = { git = "https://github.com/fortran-lang/http-client.git" }
52+
http = { git = "https://github.com/fortran-lang/http-client.git" }
53+
stdlib = "*"
2354
```
2455
## **Usage Example**
2556
The following example demonstrates how to use the http package to make a **Simple GET request** and process the response
@@ -61,6 +92,40 @@ end program simple_get
6192
```
6293
In this example, we make a GET request to the URL https://jsonplaceholder.typicode.com/todos/1 to retrieve JSON data. If the request is successful, we print the ***response code, content length, method, and content***. If the request fails, we print the ***error message***.
6394

95+
## **Getting Started Guides**
96+
> ### ***The Complete Tutorial Guide is <u> Currently in progress</u> and will be available soon.***
97+
1. ### **Installation** 👋
98+
- Installing Dependencies (Ubuntu)
99+
- Setting up the Package in your Project
100+
101+
2. ### **Making HTTP Requests** 🚀
102+
- **Sending `GET` Requests**
103+
- *Accessing Response `Content`*
104+
- *Retrieving `Status Codes`*
105+
- *Getting Response `Headers`*
106+
- *Extracting `Content Length`*
107+
- **Sending `POST` Requests**
108+
- *Sending `Data` with Requests*
109+
- *Sending `Form Data`*
110+
- *Uploading `File`*
111+
- **Sending `PUT` Requests**
112+
- **Sending `PATCH` Requests**
113+
- **Sending `DELETE` Requests**
114+
- **Sending `HEAD` Requests**
115+
116+
3. ### **Customizing Requests** ✏️
117+
- Sending Custom **Headers**
118+
- Setting Request **Timeout**
119+
- **Authentication** Option
120+
121+
4. ### **Error Handling** 🤨
122+
- Handling Unsuccessful Requests
123+
- Displaying Error Messages
124+
125+
5. ### **Real Projects** 🤖
126+
- **GitHub organization analyzer** : Retrieve valuable information about the organization repositories
127+
128+
64129
## **Contributing to project**
65130
Thank you for your interest in contributing to the `http` Fortran package! Contributions from the community are valuable in improving and enhancing the functionality of the package. This section provides a guide on how to get the code, build the library, and run examples and tests.
66131

@@ -99,7 +164,19 @@ fpm test
99164
```
100165
Running the tests will validate the behavior of the package and help identify any issues or regressions.
101166

102-
### Supported compilers
167+
### **Generating API Documentation**
168+
169+
Before generating API documentation, ensure that you have FORD installed on your system.
170+
171+
**Installation link**: [https://github.com/Fortran-FOSS-Programmers/ford#installation](https://github.com/Fortran-FOSS-Programmers/ford#installation)
172+
173+
Once FORD is set up, execute the following command to build the API documentation:
174+
175+
```bash
176+
ford ford.md
177+
```
178+
179+
### **Supported compilers**
103180

104181
http-client is known to work with the following compilers:
105182

ford.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
project: HTTP
3+
src_dir: ./src
4+
output_dir: ./doc
5+
project_github: https://github.com/fortran-lang/http-client
6+
summary: The http Fortran package provides a simple and convenient way to make HTTP requests and retrieve responses. It aims to simplify the process of interacting with web services by providing a high-level API.
7+
author: Rajkumar Dongre
8+
github: https://github.com/rajkumardongre
9+
10+
twitter: https://twitter.com/ATOM12060827
11+
author_description: Just Love to build Things 🛠️
12+
graph: true
13+
search: true
14+
display: public
15+
protected
16+
private
17+
source: true
18+
print_creation_date: true
19+
creation_date: %Y-%m-%d %H:%M %z
20+
21+
---
22+
23+
24+
{!README.md!}
25+
26+
27+

src/http.f90

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
2+
!!> This file provides the **High-Level API** for the **`HTTP`** package.
3+
!!> When the `http` module is imported into the project, all these
4+
!!> high-level functionalities become available for use.
5+
16
module http
7+
8+
!!> This Module contains all **High-level API** for the **`HTTP`** package.
9+
!!> When the `http` module is imported into the project, all these
10+
!!> high-level functionalities become available for use.
11+
212
use http_request, only: &
313
HTTP_DELETE, HTTP_GET, HTTP_HEAD, HTTP_PATCH, HTTP_POST, HTTP_PUT
414
use http_response, only: response_type
515
use http_client, only: request
616
use http_pair, only : pair_type
17+
718
end module http

0 commit comments

Comments
 (0)