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