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

Allow records as a header type and other basic types in the resource signature #935

Merged
merged 10 commits into from
Apr 5, 2022

Conversation

chamil321
Copy link
Contributor

@chamil321 chamil321 commented Mar 16, 2022

Purpose

Fixes ballerina-platform/ballerina-library#2699
Fixes ballerina-platform/ballerina-library#2807

Examples

Allow records as a header type

public type RateLimitHeaders record {|
    string x\-rate\-limit\-id;
    int x\-rate\-limit\-remaining;
    string[] x\-rate\-limit\-types;
|};

resource function get hello(@http:Header RateLimitHeaders rateLimitHeaders) returns string {
}

Support other basic types

    resource function get ofOtherPureHeaders(@http:Header int iid, @http:Header boolean bid,  
            @http:Header float[] faid, @http:Header decimal[] daid) returns json {
        //...
    }

Also types can be intersected with readonly type and be nilable

    resource function get ofOtherHeaderTypesWithReadonly(@http:Header readonly & int[] iaid,
            @http:Header readonly & float[]? faid) returns json {
        //...
     }

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec

@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #935 (9f5b2ac) into master (1c625a8) will decrease coverage by 0.04%.
The diff coverage is 83.92%.

@@             Coverage Diff              @@
##             master     #935      +/-   ##
============================================
- Coverage     80.67%   80.63%   -0.05%     
  Complexity       71       71              
============================================
  Files           347      348       +1     
  Lines         18674    18760      +86     
  Branches       4165     4183      +18     
============================================
+ Hits          15066    15127      +61     
- Misses         2803     2822      +19     
- Partials        805      811       +6     
Impacted Files Coverage Δ
.../http/api/service/signature/HeaderRecordParam.java 74.28% <74.28%> (ø)
...ib/http/api/service/signature/AllHeaderParams.java 89.41% <81.25%> (-10.59%) ⬇️
...stdlib/http/api/service/signature/HeaderParam.java 84.74% <100.00%> (+5.57%) ⬆️
.../stdlib/http/api/service/signature/ParamUtils.java 86.84% <100.00%> (-1.26%) ⬇️
...mpl/listener/states/http2/ReceivingEntityBody.java 55.00% <0.00%> (-5.00%) ⬇️
...ontractimpl/listener/http2/Http2SourceHandler.java 88.88% <0.00%> (-2.78%) ⬇️
...transport/message/Http2InboundContentListener.java 51.28% <0.00%> (-2.57%) ⬇️
...nsport/contractimpl/DefaultHttpResponseFuture.java 74.07% <0.00%> (-1.24%) ⬇️
...ransport/message/DefaultFullHttpMessageFuture.java 96.00% <0.00%> (+4.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33920eb...9f5b2ac. Read the comment docs.

@chamil321 chamil321 changed the title Allow records as a header type in the resource signature Allow records as a header type and other basic types in the resource signature Mar 24, 2022
@chamil321 chamil321 closed this Mar 25, 2022
@chamil321 chamil321 reopened this Mar 25, 2022
@chamil321 chamil321 merged commit f3db0ad into ballerina-platform:master Apr 5, 2022
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

Successfully merging this pull request may close these issues.

Add basic type support for header params Allow records to be annotated with @http:Header
3 participants