Skip to main content

Mock Rules Execution Order

In Beeceptor, the process of matching mock rules to incoming requests is key to generating mock responses. Here's how it works:

  1. Request Matching: When a request is made to your Beeceptor endpoint, it is checked against the rules you've set up.
  2. Rule Evaluation: Rules within an endpoint are prioritized from top to bottom and executed in the same order. Beeceptor evaluates these rules one by one until it finds the first rule that matches the incoming request.
  3. Rule Matched: After Beeceptor identifies a matching rule, it proceeds to generate a mocked response.
    • Templated Response: If the rule specifies a templated response, Beeceptor prepares the response according to the template defined in the rule.
    • Response Delay: When a rule suggests a delay, Beeceptor ensures that the response content is delivered after the specified delay period.
  4. Local Tunnel: (Optional) If the Local Tunnel feature is enabled, any incoming request that doesn't match your configured rules is automatically routed to your local machine's port. The response to this request is generated by your local service and returned to the caller. It's important to note that the localhost service should respond within a time frame of 60 seconds.
  5. HTTP Proxy: (Optional) If you've set up an HTTP Proxy configuration for your Beeceptor endpoint, incoming requests are directed to an upstream API, typically an external HTTP endpoint. The response from this upstream service is then relayed back to the requester.
  6. OpenAPI Specification: (Optional) If the Beeceptor endpoint is OAS enabled, incoming requests have their paths matched against the defined OpenAPI specification. Beeceptor generates mock responses based on the provided sample data or schema in the specification. This ensures that your API responses align with the structure and data defined in your OpenAPI documentation, making it easier to test your API against your documented contract.
  7. No Matching Rule: In the event that none of the defined rules match the incoming request, Beeceptor automatically sends a default response with a 200 OK status code.

These capabilities make Beeceptor a flexible tool for crafting mock APIs that closely mimic the behavior you want.