mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-19 08:47:41 +01:00
* Create WireMock.Net.MimePart project * . * REFACTOR * ILRepack * -- * ... * x * x * . * fix * public class MimePartMatcher * shared * min * . * <!--<DelaySign>true</DelaySign>--> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net;
|
|
using WireMock.Admin.Mappings;
|
|
using WireMock.Constants;
|
|
using WireMock.Http;
|
|
using WireMock.Types;
|
|
using WireMock.Util;
|
|
|
|
namespace WireMock;
|
|
|
|
internal static class ResponseMessageBuilder
|
|
{
|
|
private static readonly IDictionary<string, WireMockList<string>> ContentTypeJsonHeaders = new Dictionary<string, WireMockList<string>>
|
|
{
|
|
{ HttpKnownHeaderNames.ContentType, new WireMockList<string> { WireMockConstants.ContentTypeJson } }
|
|
};
|
|
|
|
internal static ResponseMessage Create(HttpStatusCode statusCode, string? status, Guid? guid = null)
|
|
{
|
|
return Create((int)statusCode, status, guid);
|
|
}
|
|
|
|
internal static ResponseMessage Create(int statusCode, string? status, Guid? guid = null)
|
|
{
|
|
return Create(statusCode, status, null, guid);
|
|
}
|
|
|
|
internal static ResponseMessage Create(int statusCode, string? status, string? error, Guid? guid = null)
|
|
{
|
|
var response = new ResponseMessage
|
|
{
|
|
StatusCode = statusCode,
|
|
Headers = ContentTypeJsonHeaders
|
|
};
|
|
|
|
if (status != null || error != null)
|
|
{
|
|
response.BodyData = new BodyData
|
|
{
|
|
DetectedBodyType = BodyType.Json,
|
|
BodyAsJson = new StatusModel
|
|
{
|
|
Guid = guid,
|
|
Status = status,
|
|
Error = error
|
|
}
|
|
};
|
|
}
|
|
|
|
return response;
|
|
}
|
|
|
|
internal static ResponseMessage Create(HttpStatusCode statusCode)
|
|
{
|
|
return new ResponseMessage
|
|
{
|
|
StatusCode = statusCode
|
|
};
|
|
}
|
|
} |