/// <summary> /// Matches a request by content type. /// </summary> /// <param name="builder">The request matching builder instance.</param> /// <param name="mediaType">The content type.</param> /// <returns>The request matching builder instance.</returns> public static RequestMatching ContentType(this RequestMatching builder, string mediaType) { if (mediaType is null) { throw new ArgumentNullException(nameof(mediaType)); } return(builder.ContentType(MediaTypeHeaderValue.Parse(mediaType))); }
/// <summary> /// Matches a request by content type. /// </summary> /// <param name="builder">The request matching builder instance.</param> /// <param name="contentType">The content type.</param> /// <param name="encoding">The content encoding.</param> /// <returns>The request matching builder instance.</returns> public static RequestMatching ContentType(this RequestMatching builder, string contentType, Encoding encoding) { if (contentType is null) { throw new ArgumentNullException(nameof(contentType)); } if (encoding is null) { throw new ArgumentNullException(nameof(encoding)); } var mediaType = new MediaTypeHeaderValue(contentType) { CharSet = encoding?.WebName }; return(builder.ContentType(mediaType)); }