crnk-project / crnk-framework

JSON API library for Java
Apache License 2.0
287 stars 156 forks source link

How to make requests come to controller first and then be wrapped by crnk #751

Open rehab-reda0 opened 4 years ago

rehab-reda0 commented 4 years ago

Hello I am facing some issues with crnk. 1) I need to support the put request ( any idea or workarounds how can I do that) 2) I need to modify the request before crnk executes it as the request query parameters wont match crnk query parameters so I need to modify it before going to crnk in another way we can say I need to use Spring MVC's controller to expose our rest API, which means requests comes to my controller via url mapping, then use CRNK to wrap the response as a JSON:API output. Not sure if it possible. ?? any sample ?

3)I need to customize links to add new link type and also fill its value manually

I followed the one in the crnk cheat sheet but nothing happend and it isnot appearing in the crnk response I just added in the person model @Transient @JsonApiLinksInformation private PersonLinks links;

public static class PersonLinks implements  LinksInformation
{

    private String value;

        public String getValue() {

            return "/foo";
        }

    public void setValue(String value)
    {
        this.value =value;
    }

    }
remmeier commented 4 years ago
in another way we can say I need to use Spring MVC's controller to expose our rest API, which means requests comes to my controller via url mapping, then use CRNK to wrap the response as a JSON:API output. Not sure if it possible. ?? any sample ?

you can of course make use of Crnk repositories within your code base. But at the same time you miss out on a lot of features. For example, Spring MVC does not understand the semantics of relationships. It cannot serialize more complex object graphs. Abd JSON:API/crnk comes with opionated defaults how to do things like sorting/filtering/paging. Replicating this in Spring MVC comes with significant effort and boiler-plate, whereas it comes for free in crnk. So yes doable, but probably not really what you would like to do...