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

Accept dictionary literals for HTTPHeaders #824

Merged
merged 1 commit into from
Feb 14, 2019
Merged

Accept dictionary literals for HTTPHeaders #824

merged 1 commit into from
Feb 14, 2019

Conversation

johnno1962
Copy link
Contributor

Just an idea - be able to provide dictionary literals where an HTTPHeader struct is expected. I could add the conformance in an extension if you prefer.

Motivation:

A convenience/shorthand for developers.

Modifications:

Add conformance to ExpressibleByDictionaryLiteral along with implementation.

Result:

The following is would then be legal in Vapor:

        return HTTPResponse(status: .ok, headers: ["Content-Type": "text/html"],
                            body: "<table border=1><tr><td><i>Hello</i>, plugin!")

@swift-nio-bot
Copy link

Can one of the admins verify this patch?

3 similar comments
@swift-nio-bot
Copy link

Can one of the admins verify this patch?

@swift-nio-bot
Copy link

Can one of the admins verify this patch?

@swift-nio-bot
Copy link

Can one of the admins verify this patch?

@johnno1962
Copy link
Contributor Author

johnno1962 commented Feb 13, 2019

Maybe you can close this as it is already in https://github.com/vapor/http/blob/master/Sources/HTTPKit/Message/HTTPHeaders.swift#L73. Be good if it made it up stream though. Vapor compiles with both conformances present.

Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, that works for me :)

Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That looks pretty much perfect. But we do need a (very simple) test though. One test is good enough but it's important to run this code.

@weissi weissi added the semver/minor Adds new public API. label Feb 13, 2019
@weissi weissi added this to the 2.0.0 milestone Feb 13, 2019
@johnno1962
Copy link
Contributor Author

I’ve pushed an amend with a test. The test is… untested.

Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Lgtm

@weissi
Copy link
Member

weissi commented Feb 13, 2019

@swift-nio-bot test this please

@weissi weissi merged commit f84b5b8 into apple:master Feb 14, 2019
@johnno1962
Copy link
Contributor Author

Thanks @weissi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants