Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] refactor http input to trigger each specific action, from GET, POST, PUT and FILES #187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bim-g
Copy link
Collaborator

@bim-g bim-g commented Jun 25, 2024

We used to used Input::get() method to read data from http request GET , POST and PUT without any distinction, that lead for some confusion, in case we want to deal with post, put, there was not a specific way to deal with.
The approach to have each method for a specific case it makes the module more readable and more mature, and void confusion.

@bim-g bim-g added bug Something isn't working enhancement New feature or request labels Jun 25, 2024
@bim-g bim-g added this to the Input Request milestone Jun 25, 2024
@bim-g bim-g self-assigned this Jun 25, 2024
@bim-g bim-g added this to In progress in Wepesi via automation Jun 25, 2024
@@ -36,7 +36,7 @@ function home()
*/
function changeLang()
{
Session::put('lang', Input::get("lang"));
Session::put('lang', Input::post("lang"));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this example could be on another commit of example

Comment on lines -77 to -85
$object_data = self::put();
if (isset($_POST[$item])) {
return $_POST[$item];
} else if (isset($_GET[$item])) {
return $_GET[$item];
} else if (isset($object_data[$item])) {
return $object_data[$item];
}
return null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach make everything clean

Comment on lines +51 to +62
$form_data_fragmentation = [];
$explode = explode("\r", implode("\r", explode("\n", $file_input)));
$len_Arr = count($explode);
for ($i = 1; $i < $len_Arr; $i++) {
if (!strchr($explode[$i], "----------------------------")) {
if (strlen($explode[$i]) > 0) {
$replaced = str_replace("Content-Disposition: form-data; name=", "", $explode[$i]);
array_push($fragma, $replaced);
$form_data_fragmentation[] = $replaced;
}
}
}
$len_object = count($fragma);
$len_object = count($form_data_fragmentation);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Load data from form-data should be revised, refactoring and validate while load form-data submission.
The process is not clean and testable.

if (isset($_POST[$item])) {
return $_POST[$item];
} else if (isset($self_put[$item])) {
return $self_put[$item];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is better to have a form-data method to avoid confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Wepesi
In progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant