Skip to content

UnLegitCode/rest-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RestHooks

Feedback:

Telegram

Discord: UnLegit#6190

Getting Started

Creating entity that will be parsed in JSON and from JSON

@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class User {

    final long id;
    final String name;
    double balance;
}

Creating service hook (you can use the entity as a return type, but I recommend using RestResponse, because you can use it to process the status returned by the server)

@RequestPath("127.0.0.1:1000/user")
public interface UserServiceHook {

    @RequestMethod(HttpMethod.POST)
    RestResponse<User> register(@Param("name") String name);

    @RequestMethod(HttpMethod.GET)
    RestResponse<User> get(@Path String name);

    @RequestMethod(HttpMethod.PATCH)
    RestResponse<Void> save(@Body User user);
}

Creating HTTP request executor (you can create you own request executor and json codec implementations)

RequestExecutor requestExecutor = new OkHttpRequestExecutor(new GsonCodec(new Gson()));

Implementing service hook

UserServiceHook userServiceHook = requestExecutor.implementHook(UserServiceHook.class);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages