docs: improve sample app matcher to show use of reject on match

This commit is contained in:
Alastair Crabtree
2018-05-12 01:19:01 +01:00
parent ca5056aed3
commit 9d6df1c7c8

View File

@@ -1,4 +1,5 @@
using System;
using System.Net;
using Newtonsoft.Json;
using WireMock.Matchers;
using WireMock.RequestBuilders;
@@ -152,12 +153,25 @@ namespace WireMock.Net.ConsoleApplication
server
.Given(Request.Create()
.WithPath("/reject")
.WithPath("/needs-a-key")
.UsingGet()
.WithHeader("x", "1", MatchBehaviour.RejectOnMatch)
.WithHeader("api-key", "*", MatchBehaviour.AcceptOnMatch)
.UsingAnyMethod())
.RespondWith(Response.Create()
.WithBody(@"{ ""result"": ""reject""}"));
.WithStatusCode(HttpStatusCode.OK)
.WithBody(@"{ ""result"": ""api-key found""}"));
server
.Given(Request.Create()
.WithPath("/needs-a-key")
.UsingGet()
.WithHeader("api-key", "*", MatchBehaviour.RejectOnMatch)
.UsingAnyMethod())
.RespondWith(Response.Create()
.WithStatusCode(HttpStatusCode.Unauthorized)
.WithBody(@"{ ""result"": ""api-key missing""}"));
server
.Given(Request.Create().WithPath("/nobody").UsingGet())