@@ -578,29 +578,93 @@ void HTTPRequest::delete_(std::variant<TRequestParameters<std::string>,
578578 std::visit (
579579 [&](auto && arg)
580580 {
581- auto req {DeleteRequest::builder (
582- FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
583- req.url (arg.url .url (), arg.secureCommunication )
584- .appendHeaders (arg.httpHeaders )
585- .timeout (timeout)
586- .userAgent (userAgent)
587- .outputFile (outputFile)
588- .execute ();
581+ using T = std::decay_t <decltype (arg)>;
582+ if constexpr (std::is_same_v<T, TRequestParameters<std::string>>)
583+ {
584+ auto req {DeleteRequest::builder (
585+ FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
586+ req.url (arg.url .url (), arg.secureCommunication )
587+ .template postData <const std::string&>(arg.data )
588+ .appendHeaders (arg.httpHeaders )
589+ .timeout (timeout)
590+ .userAgent (userAgent)
591+ .outputFile (outputFile)
592+ .execute ();
589593
590- std::visit (
591- [&](auto && arg)
592- {
593- using Tb = std::decay_t <decltype (arg)>;
594- if constexpr (std::is_same_v<Tb, TPostRequestParameters<const std::string&>>)
594+ std::visit (
595+ [&](auto && arg)
595596 {
596- arg.onSuccess (response);
597- }
598- else if constexpr (std::is_same_v<Tb, TPostRequestParameters<std::string&&>>)
597+ using Tb = std::decay_t <decltype (arg)>;
598+ if constexpr (std::is_same_v<Tb, TPostRequestParameters<const std::string&>>)
599+ {
600+ arg.onSuccess (response);
601+ }
602+ else if constexpr (std::is_same_v<Tb, TPostRequestParameters<std::string&&>>)
603+ {
604+ arg.onSuccess (std::move (response));
605+ }
606+ },
607+ postRequestParameters);
608+ }
609+ else if constexpr (std::is_same_v<T, TRequestParameters<std::string_view>>)
610+ {
611+ auto req {DeleteRequest::builder (
612+ FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
613+ req.url (arg.url .url (), arg.secureCommunication )
614+ .template postData <std::string_view>(arg.data )
615+ .appendHeaders (arg.httpHeaders )
616+ .timeout (timeout)
617+ .userAgent (userAgent)
618+ .outputFile (outputFile)
619+ .execute ();
620+
621+ std::visit (
622+ [&](auto && arg)
599623 {
600- arg.onSuccess (std::move (response));
601- }
602- },
603- postRequestParameters);
624+ using Tb = std::decay_t <decltype (arg)>;
625+ if constexpr (std::is_same_v<Tb, TPostRequestParameters<const std::string&>>)
626+ {
627+ arg.onSuccess (response);
628+ }
629+ else if constexpr (std::is_same_v<Tb, TPostRequestParameters<std::string&&>>)
630+ {
631+ arg.onSuccess (std::move (response));
632+ }
633+ },
634+ postRequestParameters);
635+ }
636+ else if constexpr (std::is_same_v<T, TRequestParameters<nlohmann::json>>)
637+ {
638+ const std::string data = arg.data .dump ();
639+ auto req {DeleteRequest::builder (
640+ FactoryRequestWrapper<wrapperType>::create (response, handlerType, shouldRun))};
641+ req.url (arg.url .url (), arg.secureCommunication )
642+ .template postData <const std::string&>(data)
643+ .appendHeaders (arg.httpHeaders )
644+ .timeout (timeout)
645+ .userAgent (userAgent)
646+ .outputFile (outputFile)
647+ .execute ();
648+
649+ std::visit (
650+ [&](auto && arg)
651+ {
652+ using Tb = std::decay_t <decltype (arg)>;
653+ if constexpr (std::is_same_v<Tb, TPostRequestParameters<const std::string&>>)
654+ {
655+ arg.onSuccess (response);
656+ }
657+ else if constexpr (std::is_same_v<Tb, TPostRequestParameters<std::string&&>>)
658+ {
659+ arg.onSuccess (std::move (response));
660+ }
661+ },
662+ postRequestParameters);
663+ }
664+ else
665+ {
666+ throw std::runtime_error (" Invalid type" );
667+ }
604668 },
605669 requestParameters);
606670 }
0 commit comments