-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add spring boot starter. refactoring for easier controller config
- Loading branch information
Showing
55 changed files
with
1,325 additions
and
377 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
20 changes: 20 additions & 0 deletions
20
up-annotations/src/main/java/com/github/restup/annotations/Resource.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,20 @@ | ||
package com.github.restup.annotations; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Optional tag annotation for resources, which may aid component scanning. | ||
* | ||
* @author abuttaro | ||
* | ||
*/ | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
public @interface Resource { | ||
|
||
} |
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
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
38 changes: 38 additions & 0 deletions
38
...rc/main/java/com/github/restup/controller/content/negotiation/ContentNegotiatorChain.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,38 @@ | ||
package com.github.restup.controller.content.negotiation; | ||
|
||
import com.github.restup.controller.model.ParsedResourceControllerRequest; | ||
import com.github.restup.controller.model.ResourceControllerRequest; | ||
import com.github.restup.controller.model.ResourceControllerResponse; | ||
|
||
public class ContentNegotiatorChain implements ContentNegotiator { | ||
|
||
private final ContentNegotiator[] contentNegotiators; | ||
|
||
public ContentNegotiatorChain(ContentNegotiator... contentNegotiators) { | ||
this.contentNegotiators = contentNegotiators; | ||
} | ||
|
||
@Override | ||
public <T> boolean accept(ResourceControllerRequest request) { | ||
return null != getContentNegotiator(request); | ||
} | ||
|
||
@Override | ||
public <T> Object formatResponse(ParsedResourceControllerRequest<T> request, ResourceControllerResponse response, Object result) { | ||
return getContentNegotiator(request).formatResponse(request, response, result); | ||
} | ||
|
||
/** | ||
* @return ContentNegotiator for content type passed | ||
* @throws RequestErrorException if content type is not supported | ||
*/ | ||
private ContentNegotiator getContentNegotiator(ResourceControllerRequest request) { | ||
for (ContentNegotiator contentNegotiator : contentNegotiators) { | ||
if (contentNegotiator.accept(request)) { | ||
return contentNegotiator; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.