void AddUriTemplateHandler( string baseAddress, string template, string[] methods, RequestHandlingFunc handlingFunc, string name) { server.AddHandler( new UriTemplateRequestHandler( baseAddress, template, methods, handlingFunc, name)); }
public RegexRequestHandler( string baseAddress, string relativeUriRegex, string[] methods, RequestHandlingFunc handlingFunc, string name) : base(name) { baseAddress.ThrowIfNull(nameof(baseAddress)); relativeUriRegex.ThrowIfNull(nameof(relativeUriRegex)); handlingFunc.ThrowIfNull(nameof(handlingFunc)); this.methods = methods ?? EmptyArray <string> .Instance; this.handlingFunc = handlingFunc; this.baseAddress = new Uri(baseAddress); this.relativeUriRegex = new Regex(relativeUriRegex); }
public UriTemplateRequestHandler( string baseAddress, string template, string[] methods, RequestHandlingFunc handlingFunc, string name) : base(name) { baseAddress.ThrowIfNull(nameof(baseAddress)); template.ThrowIfNull(nameof(template)); handlingFunc.ThrowIfNull(nameof(handlingFunc)); this.handlingFunc = handlingFunc; this.methods = methods ?? EmptyArray <string> .Instance; uriTemplate = new UriTemplate(template); this.baseAddress = new Uri(baseAddress, UriKind.Absolute); }
/// <summary> /// Create a <see cref="DelegatedRequestHandler"/> instance. /// </summary> /// <param name="matcher"> /// A delegate determines that if current handler can handle the HTTP request message. /// </param> /// <param name="handleFunc"> /// A delegate to create and return HTTP response message. Usually this is defined by /// test writer. /// </param> /// <param name="name"> /// The name of the handler. This parameter is very helpful if you want to track /// the calling history. /// </param> /// <exception cref="ArgumentNullException"> /// The <paramref name="matcher"/> is <c>null</c> or the <paramref name="handleFunc"/> /// is <c>null</c>. /// </exception> public DelegatedRequestHandler(MatchingFunc matcher, RequestHandlingFunc handleFunc, string name) : base(name) { this.handleFunc = handleFunc ?? throw new ArgumentNullException(nameof(handleFunc)); this.matcher = matcher ?? throw new ArgumentNullException(nameof(matcher)); }