dotronglong / faker

A fake api server built in Java
38 stars 6 forks source link

Header not matching value #57

Open Xaponeis opened 2 weeks ago

Xaponeis commented 2 weeks ago

I'm trying to use Faker with the " header" property like bellow, but the server ignores the "header-value", any value that I use for "X-custom-header", it returns the response. It only matches with the header title, if I do not send the header "X-custom-header", then no response is returned.

Anyone having this issue?

Example:

{
  "request": {
    "method": "GET",
    "path": "^\\/my-url\\?param1=.*\\&param2=my-param$",
    "headers": {
      "X-custom-header": "header-value"
    }
  },
  "response": {
     ....
dotronglong commented 2 weeks ago

@Xaponeis I think we only check for header's name in this case. I may look into it.

Xaponeis commented 2 weeks ago

Thank you, really nice project, it was just what I was looking for, a easy to setup and lightweight API mocker.

Xaponeis commented 2 weeks ago

@dotronglong First time playing aroung with Kotlin: Allow matching header's value with regex.

That would solve my issue, although the downside I see is if someone is using a 'stable' tag in a docker image, could break the json mock if they are not expecting to match the header value. Maybe changing the tag version or creating a variable for when the header´s value is desired.