Skip to content

Commit

Permalink
Modify based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
Thevakumar-Luheerathan committed Sep 13, 2022
1 parent 8b6c758 commit 6eab2db
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 132 deletions.
42 changes: 23 additions & 19 deletions ballerina-tests/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -35,93 +35,97 @@ listener af:HttpListener ep2 = new ();
@http:ServiceConfig {
treatNilableAsOptional: false
}
service /hello on ep2 {
resource function post httpHeaderTest8(@http:Header string? Hoste) returns string? {
service /httpHeader on ep2 {
resource function post nonTreatNilAsOpt\-Nil\-noHeaderTest(@http:Header string? Hoste) returns string? {
return Hoste;
}

resource function post httpHeaderTest14(@http:Header string Hoste) returns string {
resource function post nonTreatNilAsOpt\-nonNil\-noHeaderTest(@http:Header string Hoste) returns string {
return Hoste;

}

resource function post httpHeaderTest15(@http:Header string Hos) returns string {
resource function post nonTreatNilAsOpt\-nonNil\-HeaderTest(@http:Header string Hos) returns string {
return Hos;

}

resource function post httpHeaderTest16(@http:Header string? Hos) returns string? {
resource function post nonTreatNilAsOpt\-Nil\-HeaderTest(@http:Header string? Hos) returns string? {
return Hos;

}
}

listener af:HttpListener ep = new ();
listener af:HttpListener ep3 = new ();

service /hello on ep {
resource function post httpHeaderTest1(@http:Header {name: "Content-Type"} string contentType) returns string {
service /httpHeader on ep3 {
resource function post retrFromAnnotField(@http:Header {name: "Content-Type"} string contentType) returns string {

return contentType;
}

resource function post httpHeaderTest2(@http:Header string Host) returns string {
resource function post retrFromParam(@http:Header string Host) returns string {

return Host;

}

resource function post httpHeaderTest3(@http:Header {name: "Content-Length"} int contentLength) returns int {
resource function post retrSingleVal(@http:Header {name: "Content-Length"} int contentLength) returns int {

return contentLength + 10;

}

resource function post httpHeaderTest4(@http:Header {name: "Content-Length"} int[] contentLength) returns int {
resource function post retrArrVal(@http:Header {name: "Content-Length"} int[] contentLength) returns int {

return contentLength[0] + 15;

}

resource function post httpHeaderTest5(@http:Header string[] test) returns string {
resource function post retrArrValStr(@http:Header string[] test) returns string {
return test[0];

}

resource function post httpHeaderTest6(@http:Header RateLimitHeaders rateLimiters) returns int {
resource function post retrAsRecord(@http:Header RateLimitHeaders rateLimiters) returns int {
return rateLimiters.Content\-Length + 100;

}

resource function post httpHeaderTest7(@http:Header string? Host) returns string? {
resource function post retrNilable(@http:Header string? Host) returns string? {
return Host;

}

resource function post httpHeaderTest9(@http:Header string Hoste) returns string {
resource function post treatNilAsOpt\-nonNil\-noHeaderTest(@http:Header string Hoste) returns string {
return Hoste;

}

resource function post httpHeaderTest10(@http:Header string Hos) returns string {
resource function post treatNilAsOpt\-nonNil\-HeaderTest(@http:Header string Hos) returns string {
return Hos;

}

resource function post httpHeaderTest11(@http:Header NoHeaderVal noHeaderVal) returns int {
resource function post retrAsRecordNoField(@http:Header NoHeaderVal noHeaderVal) returns int {
return noHeaderVal.Content\-Length + 100;

}

resource function post httpHeaderTest12(@http:Header string? Hoste) returns string? {
resource function post treatNilAsOpt\-Nil\-noHeaderTest(@http:Header string? Hoste) returns string? {
return Hoste;

}

resource function post httpHeaderTest13(@http:Header string? Hos) returns string? {
resource function post treatNilAsOpt\-Nil\-HeaderTest(@http:Header string? Hos) returns string? {
return Hos;

}
}
listener af:HttpListener ep = new ();

service /hello on ep {

resource function default all() returns @af:HttpOutput string {
return "Hello from all";
}
Expand Down
14 changes: 7 additions & 7 deletions ballerina-tests/tests/resources/httpHeaderTest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Data":{
"httpPayload":{
"Url":"https://az-func-http-test.azurewebsites.net/api/hello/FUNC_NAME",
"Url":"https://az-func-http-test.azurewebsites.net/api/httpHeader/FUNC_NAME",
"Method":"POST",
"Query":{

Expand Down Expand Up @@ -59,10 +59,10 @@
"45.121.88.92:53880"
],
"X-Original-URL":[
"/api/hello/FUNC_NAME"
"/api/httpHeader/FUNC_NAME"
],
"X-WAWS-Unencoded-URL":[
"/api/hello/FUNC_NAME"
"/api/httpHeader/FUNC_NAME"
]
},
"Params":{
Expand All @@ -83,7 +83,7 @@
"RoleClaimType":"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
}
],
"Body":"hello"
"Body":"httpHeader"
}
},
"Metadata":{
Expand All @@ -107,11 +107,11 @@
"X-ARR-SSL":"2048|256|CN=Microsoft Azure TLS Issuing CA 01, O=Microsoft Corporation, C=US|CN=*.azurewebsites.net, O=Microsoft Corporation, L=Redmond, S=WA, C=US",
"X-Forwarded-TlsVersion":"1.2",
"X-Forwarded-For":"45.121.88.92:53880",
"X-Original-URL":"/api/hello/FUNC_NAME",
"X-WAWS-Unencoded-URL":"/api/hello/FUNC_NAME"
"X-Original-URL":"/api/httpHeader/FUNC_NAME",
"X-WAWS-Unencoded-URL":"/api/httpHeader/FUNC_NAME"
},
"sys":{
"MethodName":"post-hello-FUNC_NAME",
"MethodName":"post-httpHeader-FUNC_NAME",
"UtcNow":"2022-09-01T10:12:54.2952774Z",
"RandGuid":"f891f95b-cc04-4e8c-b440-24b8da192b28"
}
Expand Down
Loading

0 comments on commit 6eab2db

Please sign in to comment.