-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Http request and response headers available to repositories and …
…modules #94 HttpRequestContextAware introduced. Instances loaded by ServiceDiscovery are checked for this interfaced and setup accordingly.
- Loading branch information
Showing
4 changed files
with
81 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
9 changes: 9 additions & 0 deletions
9
crnk-core/src/main/java/io/crnk/core/engine/http/HttpRequestContextAware.java
This file contains 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,9 @@ | ||
package io.crnk.core.engine.http; | ||
|
||
/** | ||
* Can be implemented by repositories to get access to request parameters. | ||
*/ | ||
public interface HttpRequestContextAware { | ||
|
||
void setHttpRequestContextProvider(HttpRequestContextProvider requestContextProvider); | ||
} |
31 changes: 31 additions & 0 deletions
31
crnk-core/src/test/java/io/crnk/core/engine/http/HttpRequestContextAwareTest.java
This file contains 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,31 @@ | ||
package io.crnk.core.engine.http; | ||
|
||
import io.crnk.core.boot.CrnkBoot; | ||
import io.crnk.core.engine.url.ConstantServiceUrlProvider; | ||
import io.crnk.core.module.Module; | ||
import io.crnk.core.module.discovery.ReflectionsServiceDiscovery; | ||
import io.crnk.core.resource.registry.ResourceRegistryBuilderTest; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import java.io.IOException; | ||
|
||
public class HttpRequestContextAwareTest { | ||
|
||
interface HttTestModule extends Module, HttpRequestContextAware { | ||
|
||
} | ||
|
||
@Test | ||
public void check() throws IOException { | ||
HttTestModule testModule = Mockito.mock(HttTestModule.class); | ||
|
||
CrnkBoot boot = new CrnkBoot(); | ||
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost:8080")); | ||
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(ResourceRegistryBuilderTest.TEST_MODELS_PACKAGE)); | ||
boot.addModule(testModule); | ||
boot.boot(); | ||
|
||
Mockito.verify(testModule, Mockito.times(1)).setHttpRequestContextProvider(Mockito.any(HttpRequestContextProvider.class)); | ||
} | ||
} |
This file contains 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