mock-webserver icon indicating copy to clipboard operation
mock-webserver copied to clipboard

Feature: Mock a dynamic url

Open didslm opened this issue 5 years ago • 3 comments

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

didslm avatar Nov 15 '19 13:11 didslm

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.

donatj avatar Nov 15 '19 16:11 donatj

It would be very helpful. Having HTTP 200 responses when something is not mocked is not ideal.

itsjavi avatar Aug 02 '21 11:08 itsjavi

@ellipsis-dev can you give this a shot?

donatj avatar May 09 '24 21:05 donatj