question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is KatharsisProperties.RESOURCE_DEFAULT_DOMAIN really required?

See original GitHub issue

From @chabala on July 13, 2016 22:53

I see in the example code that specifying RESOURCE_DEFAULT_DOMAIN is recommended.

https://github.com/katharsis-project/katharsis-examples/blob/master/jersey-example/src/main/java/io/katharsis/example/jersey/JerseyApplication.java#L23

In fact, while Katharsis will serve resources without having that property set, all the links that are generated will have null in the place where the URI scheme and hostname were expected.

This seems unnecessary to configure, as JAX-RS will inject a UriInfo object that can be used to obtain that information: https://jersey.java.net/documentation/latest/uris-and-links.html

I expect a call to UriInfo.getBaseUri() would net the same information that is being manually supplied.

I could submit a PR for this, but I thought we might discuss it first.

Copied from original issue: katharsis-project/katharsis-rs#40

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (13 by maintainers)

github_iconTop GitHub Comments

4reactions
chb0githubcommented, Aug 12, 2016

Second idea (an probably easier to implement inside katharsis):

public interface ServiceUrlProvider {
    String getUrl();
}
public class ResourceRegistry {
    private final Map<Class, RegistryEntry> resources = new HashMap<>();
    private final ServiceUrlProvider serviceUrlProvider;
    private final Logger logger = LoggerFactory.getLogger(ResourceRegistry.class);

    public ResourceRegistry(ServiceUrlProvider serviceUrlProvider) {
        this.serviceUrlProvider = serviceUrlProvider;
    }

   public String getResourceUrl(Class clazz) {
        return serviceUrlProvider.getUrl() + "/" + getResourceType(clazz);
    }
@Component
public class DefaultServiceUrlProvider implements ServiceUrlProvider {

    @Value("${katharsis.pathPrefix}")
    private String pathPrefix;

    @Resource
    private HttpServletRequest request;

    public String getUrl() {
        String scheme = request.getScheme();
        String host = request.getHeader("host");
        String resourceType = registry.getResourceType(clazz);
        return scheme + "://" + host + pathPrefix;
    }
}

Doing it this way means you can offload the implementation to katharsis-rs and have it inject the implementation.

0reactions
chb0githubcommented, Oct 3, 2016

Closed by #140

Read more comments on GitHub >

github_iconTop Results From Across the Web

katharsis-docs/user-docs.rst at master - GitHub
Katharsis require an instance of every resources repository it finds. To provide them, JsonServiceLocator interface has to be implemented. The created instance ...
Read more >
Katharsis Query Parameters Capabilities - Stack Overflow
My team is trying to use the query parameters for Katharsis and found that they really don't seem to do anything except on...
Read more >
JSON API - Spring Boot Katharsis Example
A detailed step-by-step tutorial on how to provide and consume a RESTful Hello World API using JSON API, Katharsis and Spring Boot.
Read more >
DomainConfiguration - AWS Serverless Application Model
A list of the basepaths to configure with the Amazon API Gateway domain name. Type: List. Required: No. Default: /. AWS CloudFormation compatibility:...
Read more >
Enhanced Domains - Salesforce Help
With no instance names, enhanced My Domain URLs are easier for users to remember and don't change when your org is moved to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found