Skip to content

Commit

Permalink
Add docs for internal http modules
Browse files Browse the repository at this point in the history
  • Loading branch information
connorslade committed Sep 24, 2023
1 parent 85c5c85 commit 2bdde3c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/proto/http/content_type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Common MIME types for HTTP responses.

use crate::{headers::ContentType, Header};

use super::mime::{self, Mime};
Expand Down
4 changes: 3 additions & 1 deletion lib/proto/http/date.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! HTTP date formatting.

const DAYS: [&str; 7] = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
const MONTHS: [&str; 12] = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
Expand All @@ -15,7 +17,7 @@ fn days_in_month(month: u8, year: u16) -> u8 {
}
}

/// Returns the current date in the IMF-fixdate format.
/// Returns the specified epoch (seconds) in the IMF-fixdate format.
/// Example: `Sun, 06 Nov 1994 08:49:37 GMT`
pub fn imp_date(epoch: u64) -> String {
let seconds = epoch % 60;
Expand Down
2 changes: 2 additions & 0 deletions lib/proto/http/headers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Contains all the header structs that can be used with HTTP requests and responses.

use std::{borrow::Cow, fmt::Display};

use crate::{
Expand Down
2 changes: 2 additions & 0 deletions lib/proto/http/method.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! HTTP Methods.

use std::{fmt, str::FromStr};

/// HTTP Methods.
Expand Down
8 changes: 7 additions & 1 deletion lib/proto/http/mime.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Mime types used in headers.

use std::{borrow::Cow, fmt::Display};

/// A MIME type.
pub struct Mime {
r#type: Cow<'static, str>,
subtype: Cow<'static, str>,
Expand Down Expand Up @@ -34,7 +37,10 @@ macro_rules! mime {

macro_rules! define_mimes {
($($name:ident => $_type:ident / $_subtype:ident),*) => {
$( pub const $name: Mime = mime!($_type / $_subtype); )*
$(
#[doc = concat!("The ", stringify!($name), " MIME type. (`", stringify!($_type), "/", stringify!($_subtype), "`)")]
pub const $name: Mime = mime!($_type / $_subtype);
)*
};
}

Expand Down
2 changes: 2 additions & 0 deletions lib/proto/http/query.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Query parameters for HTTP requests.

use std::{
fmt,
ops::{Deref, DerefMut},
Expand Down

0 comments on commit 2bdde3c

Please sign in to comment.