Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bardiademon/vertxrest
Vert.x Rest
https://github.com/bardiademon/vertxrest
bardiademon java rest rest-api vertx vertx-web
Last synced: about 1 month ago
JSON representation
Vert.x Rest
- Host: GitHub
- URL: https://github.com/bardiademon/vertxrest
- Owner: bardiademon
- Created: 2023-05-26T07:50:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-14T21:47:37.000Z (over 1 year ago)
- Last Synced: 2024-10-09T20:42:07.418Z (about 1 month ago)
- Topics: bardiademon, java, rest, rest-api, vertx, vertx-web
- Language: Java
- Homepage: https://bardiademon.com
- Size: 72.3 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# VertxRest
## This is the repository for Vert.x rest.
### Vert.x Rest for convenience in rest api programming
# How use
```java
@Rest(method = RequestMethod.POST, path = {"/tst" , "/test"}, db = false, dto = TestDto.class, validator = TestValidation.class)
public final class TestRest extends RestController {
@Override
public void handler(final RestHandler restHandler) throws Exception {
restHandler.success(Response.TEST);
}
}
```### Rest
```java
@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
```java
public abstract class RestController {public RestController() {
}abstract public void restHandler(final Handler restHandler) throws Exception;
}
```### Handler
```java
public interface Handler {
void fail(final Throwable throwable , final ServerResponse response);void fail(final Throwable throwable);
void fail(final Throwable throwable , final RESPONSE info , final Response response);
void fail(final ServerResponse response);
void fail(final RESPONSE info , final Response response);
void fail(final Response response);
void success(final ServerResponse 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
🌟 Spread the word!If you want to say thank you:
- Add a GitHub Star to the project!
- Follow my GitHub [bardiademon](https://github.com/bardiademon)
⚠️ License & 📝 Creditsby bardiademon [https://bardiademon.com](https://www.bardiademon.com)