HttpDelete.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Newtonsoft.Json;
  2. namespace AmrControl.Common.HttpClients
  3. {
  4. public class HttpDelete : BaseHttpClient
  5. {
  6. public HttpDelete(HttpClient httpClient, string baseUri) : base(httpClient, baseUri)
  7. {
  8. }
  9. protected override HttpMethod getMethod()
  10. {
  11. return HttpMethod.Delete;
  12. }
  13. protected override HttpContent? handleData<T>(T data)
  14. {
  15. return null;
  16. }
  17. protected override string reHandleUrl<T>(string url, T data)
  18. {
  19. string uri = base.reHandleUrl(url, data);
  20. if (data != null)
  21. {
  22. Dictionary<string, string> dict = convertObj2Dict<T>(data);
  23. //将参数放到url中
  24. foreach (var item in dict)
  25. {
  26. if (uri.IndexOf("?") > 0)
  27. {
  28. uri += "&" + item.Key + "=" + item.Value;
  29. }
  30. else
  31. {
  32. uri += "?" + item.Key + "=" + item.Value;
  33. }
  34. }
  35. }
  36. return uri;
  37. }
  38. }
  39. }