Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
fix: header menu add more defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
PThorpe92 committed Apr 21, 2024
1 parent 24a1087 commit 04991a4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/display/menuopts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,14 @@ pub const METHOD_MENU_OPTIONS: [&str; 7] = [
"PATCH",
"HEAD",
];
pub const HEADER_MENU_OPTIONS: [&str; 5] = [
pub const HEADER_MENU_OPTIONS: [&str; 9] = [
"Add Custom Header 󰖟 ",
"Add Content-Type: Application/Json  ",
"Add Accept: Application/Json  ",
"Add Content-Type: application/json  ",
"Add Content-Type: application/xml  ",
"Add Content-Type: application/X-WWW-Form-Urlencoded  ",
"Add Accept: application/json  ",
"Add Accept: text/html  ",
"Add Accept: application/xml  ",
"Enable Response Headers 󰰀 ",
"Return to request menu  ",
];
Expand Down
5 changes: 4 additions & 1 deletion src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ impl AppOptions {
)
}
pub fn should_append(&self) -> bool {
matches!(self, Self::Headers(_) | Self::NewCookie(_))
matches!(
self,
Self::Headers(_) | Self::NewCookie(_) | Self::ContentHeaders(_)
)
}
pub fn replace_value(&mut self, val: String) {
match self {
Expand Down
38 changes: 31 additions & 7 deletions src/screens/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,53 @@ pub fn handle_headers_screen(app: &mut App, frame: &mut Frame<'_>) {

match app.selected {
// add custom headers
Some(0) => app.goto_screen(&Screen::InputMenu(InputOpt::Headers)),
//
// "Add Content-Type: application/json  ",
// "Add Content-Type: application/xml  ",
// "Add Content-Type: application/X-WWW-Form-Urlencoded  ",
// "Add Accept: application/json  ",
// "Add Accept: text/html  ",
// "Add Accept: application/xml  ",
Some(0) => app.goto_screen(&Screen::RequestMenu(Some(InputOpt::Headers))),
// add content-type application/json
Some(1) => {
app.add_app_option(AppOptions::ContentHeaders(HeaderKind::ContentType(
String::from("application/json"),
)));
}
//
// add accept application/json
Some(2) => {
app.add_app_option(AppOptions::ContentHeaders(HeaderKind::ContentType(
String::from("application/xml"),
)));
}
Some(3) => {
app.add_app_option(AppOptions::ContentHeaders(HeaderKind::ContentType(
String::from("application/www-form-urlencoded"),
)));
}
// add accept application/json
Some(4) => {
app.add_app_option(AppOptions::ContentHeaders(HeaderKind::Accept(
String::from("application/json"),
)));
}
//
Some(5) => {
app.add_app_option(AppOptions::ContentHeaders(HeaderKind::ContentType(
String::from("text/html"),
)));
}
// add accept application/json
Some(6) => {
app.add_app_option(AppOptions::ContentHeaders(HeaderKind::Accept(
String::from("application/xml"),
)));
}
// accept headers in response
Some(3) => {
Some(7) => {
app.add_app_option(AppOptions::EnableHeaders);
}
//
// return to request menu
Some(4) => app.goto_screen(&Screen::RequestMenu(None)),
Some(8) => app.goto_screen(&Screen::RequestMenu(None)),
_ => {}
}
}

0 comments on commit 04991a4

Please sign in to comment.