Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Header Key name reformat by mock service? #38

Open
calvinlyc opened this issue Feb 11, 2016 · 2 comments
Open

Custom Header Key name reformat by mock service? #38

calvinlyc opened this issue Feb 11, 2016 · 2 comments

Comments

@calvinlyc
Copy link

We have a custom header which has a key such as "APP_AUTH" and I'd like to keep this key in the pact contract. However, I believe pact-mock_serivce helps me reformat the custom header to be "App-Auth" and breaks the contract on the provider side.

After look around the source code with my bad ruby knowledge. I believe the source code is under pact-mock_service/lib/pact/consumer/mock_service/rack_request_helper.rb

line 47:

def standardise_header header
header.gsub(/^HTTP_/, '').split("_").collect{|word| word[0] + word[1..-1].downcase}.join("-")
end

Would you please tell me whether I can still keep the original contract format rather than to standardise it? I know "APP_AUTH" maybe is not a good name, however it's have been used by a lot of services which we can not easily modify.

Thanks for your help and looking forward to your reply. :)

@calvinlyc calvinlyc changed the title Custom Header Reformat...? Custom Header Key name reformat by mock service? Feb 11, 2016
@bethesque
Copy link
Member

That's a tricky one. The code that you have found converts the Rack headers into HTTP headers. You can read about Rack headers here: http://www.rubydoc.info/github/rack/rack/file/SPEC There's no configuration to ignore particular headers unfortunately.

If you want to keep APP_AUTH, I'd recommend monkey patching that method to ignore that particular header ;) It's an unusual corner case, not really one that I particularly want to add support for.

@bethesque
Copy link
Member

Sorry for slow reply, I'm on mat leave at the moment, @sergei-matheson will be able to help you out if you need further support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants