-
Notifications
You must be signed in to change notification settings - Fork 827
JAV-354 Servlet rest signature #148
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a771cdb
JAV-354 BufferInputStream extend from ServletInputStream, not InputSt…
bac087e
JAV-354 rest codec should not auto close httpServletRequest inputStream
8e1105d
JAV-354 wrap standard HttpServletRequest to support reset inputStream…
b4a4bd4
JAV-354 wrap to CachedHttpServletRequest by configuration, to support…
1bf67c8
JAV-354 create http client and server filter interface
75a6e3e
JAV-354 extract after receive http response logic to httpClientFilter
914cc5a
JAV-354 delete useless parameter.
9365b98
JAV-354 call HttpClientFilter.beforeSendRequest.
2f71284
JAV-354 call HttpServerFilter.afterReceiveRequest
8c7d38f
JAV-354 fast get bytes from inputstream/Buffer/ByteBuf
66317ca
JAV-354 call HttpServerFilter.beforeSendResponse
2781f49
JAV-354 add demo for signature of servlet rest
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
common/common-rest/src/main/java/io/servicecomb/common/rest/filter/HttpClientFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2017 Huawei Technologies Co., Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.servicecomb.common.rest.filter; | ||
|
||
import io.servicecomb.core.Invocation; | ||
import io.servicecomb.swagger.invocation.Response; | ||
import io.vertx.core.buffer.Buffer; | ||
import io.vertx.core.http.HttpClientRequest; | ||
import io.vertx.core.http.HttpClientResponse; | ||
|
||
public interface HttpClientFilter { | ||
int getOrder(); | ||
|
||
// bodyBytes maybe be null | ||
void beforeSendRequest(Invocation invocation, HttpClientRequest clientRequest, Buffer requestBodyBuffer); | ||
|
||
// if finished, then return a none null response | ||
// if return a null response, then sdk will call next filter.afterReceive | ||
Response afterReceiveResponse(Invocation invocation, HttpClientResponse httpResponse, Buffer responseBodyBuffer) | ||
throws Exception; | ||
} |
33 changes: 33 additions & 0 deletions
33
common/common-rest/src/main/java/io/servicecomb/common/rest/filter/HttpServerFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2017 Huawei Technologies Co., Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.servicecomb.common.rest.filter; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import io.servicecomb.core.Invocation; | ||
import io.servicecomb.swagger.invocation.Response; | ||
|
||
public interface HttpServerFilter { | ||
int getOrder(); | ||
|
||
//if check failed, then return failed response | ||
Response afterReceiveRequest(Invocation invocation, HttpServletRequest request); | ||
|
||
// invocation maybe null | ||
void beforeSendResponse(Invocation invocation, HttpServletResponse response, byte[] bodyBytes, int length); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
common/common-rest/src/test/java/io/servicecomb/common/rest/codec/TestRestObjectMapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2017 Huawei Technologies Co., Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.servicecomb.common.rest.codec; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.core.JsonParser.Feature; | ||
|
||
public class TestRestObjectMapper { | ||
@Test | ||
public void testAutoCloseSource() { | ||
Assert.assertFalse(RestObjectMapper.INSTANCE.getFactory().isEnabled(Feature.AUTO_CLOSE_SOURCE)); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to give a java doc comment. spell non null ? or a response that is not null