Giter VIP home page Giter VIP logo

vertxrest's Introduction

VertxRest

This is the repository for Vert.x rest.

Vert.x Rest for convenience in rest api programming

How use

@Rest(method = RequestMethod.POST, path = {"/tst" , "/test"}, db = false, dto = TestDto.class, validator = TestValidation.class)
public final class TestRest extends RestController<TestDto, String> {
    @Override
    public void handler(final RestHandler<TestDto, String> restHandler) throws Exception {
        restHandler.success(Response.TEST);
    }
}

Rest

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Rest {
    RequestMethod method() default RequestMethod.ANY;

    String[] path() default {};

    String produces() default "application/json";

    String consumes() default "application/json";

    boolean db() default true;

    Class<?> dto() default NothingDto.class;

    Class<?>[] validator() default {};

    boolean authentication() default false;

    UserRole[] roles() default UserRole.ANY;
}

Rest Specifies that the class is a Rest

  • method: Specifies the request method
  • path: Specifies the route
  • produces: Specifies what this request produces
  • consumes: Specifies what this request consumes
  • db: Determines whether this Rest requires a database connection or not
  • dto: Defines the input Dto class
  • validator: It defines the classes that are used to validate the DTO
  • authentication: Checking the user login with the token created from sign-in rest
  • roles: If authentication is enabled, this item is checked and the access level is determined

RestController

public abstract class RestController<REQUEST, RESPONSE> {

    public RestController() {
    }

    abstract public void restHandler(final Handler<REQUEST, RESPONSE> restHandler) throws Exception;
}

Handler

public interface Handler<REQUEST, RESPONSE> {
    void fail(final Throwable throwable , final ServerResponse<RESPONSE> response);

    void fail(final Throwable throwable);

    void fail(final Throwable throwable , final RESPONSE info , final Response response);

    void fail(final ServerResponse<RESPONSE> response);

    void fail(final RESPONSE info , final Response response);

    void fail(final Response response);

    void success(final ServerResponse<RESPONSE> serverResponse);

    void success(final RESPONSE info , final Response response);

    void success(final RESPONSE info);

    void success(final Response response);

    REQUEST request();

    RoutingContext routingContext();

    Vertx vertx();

    SQLConnection sqlConnection();

    UserEntity user();
}

๐Ÿ’ป Technologies

Java Vert.x

๐ŸŒŸ Spread the word!

If you want to say thank you:

  • Add a GitHub Star to the project!
  • Follow my GitHub bardiademon

โš ๏ธ License & ๐Ÿ“ Credits

by bardiademon https://bardiademon.com

vertxrest's People

Contributors

bardiademon avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.