mock-webserver
mock-webserver copied to clipboard
Feature: Mock a dynamic url
What if we could mock an endpoint like this /endpoint/product/*
So then it would not matter what parameter we send in the * we would get the same response.
<?php
use donatj\MockWebServer\MockWebServer;
use donatj\MockWebServer\RequestInfo;
use donatj\MockWebServer\Response;
require 'vendor/autoload.php';
$server = new MockWebServer();
$server->start();
$url = $server->setResponseOfPath("/api/endpoint/product/*", new Response('abc'));
//request '/api/endpoint/product/1' will result in: abc
I think this would be a useful feature to have.
Off the top of my head I'm not sure a great way to implement it but I will certainly look into it.
It would be very helpful. Having HTTP 200 responses when something is not mocked is not ideal.
@ellipsis-dev can you give this a shot?