Skip to content

Commit

Permalink
Re-Introduce Vert.x Web specific HttpException to reduce API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jotschi committed Oct 20, 2023
1 parent 2342a00 commit a73b457
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.vertx.ext.web.api.service.RouteToEBServiceHandler;
import io.vertx.ext.web.api.service.ServiceRequest;
import io.vertx.ext.web.api.service.ServiceResponse;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;
import io.vertx.ext.web.validation.ValidationHandler;
import io.vertx.ext.web.validation.builder.ValidationHandlerBuilder;
import io.vertx.json.schema.SchemaRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
*
* @author <a href="mailto:plopes@redhat.com">Paulo Lopes</a>
*/
public final class HttpException extends RuntimeException {
public class HttpException extends RuntimeException {

public static final HttpException UNAUTHORIZED = new HttpException(401);
public static final HttpException BAD_REQUEST = new HttpException(400);
public static final HttpException BAD_METHOD = new HttpException(405);

private final int statusCode;
private final String payload;

Expand Down
6 changes: 6 additions & 0 deletions vertx-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
<groupId>io.vertx</groupId>
<artifactId>vertx-auth-common</artifactId>
</dependency>
<!-- Remove this dependency once code got moved to vertx-auth-common -->
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-auth-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-auth-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.vertx.ext.web.handler;

/**
* @see io.vertx.ext.web.common.HttpException2
*/
public final class HttpException extends io.vertx.ext.web.common.HttpException {

public HttpException() {
super();
}

public HttpException(int statusCode) {
super(statusCode);
}

public HttpException(int statusCode, Throwable cause) {
super(statusCode, cause);
}

public HttpException(int statusCode, String payload) {
super(statusCode, payload);
}

public HttpException(int statusCode, String payload, Throwable cause) {
super(statusCode, payload, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import io.vertx.ext.auth.authentication.TokenCredentials;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.APIKeyHandler;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;
import io.vertx.ext.web.impl.RoutingContextInternal;

import java.util.function.Function;

import static io.vertx.ext.web.common.HttpException.UNAUTHORIZED;
import static io.vertx.ext.web.handler.HttpException.UNAUTHORIZED;

/**
* @author <a href="mailto:pmlopes@gmail.com">Paulo Lopes</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.vertx.ext.auth.authentication.AuthenticationProvider;
import io.vertx.ext.auth.common.handler.AuthenticationHandlerInternal;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;
import io.vertx.ext.web.handler.*;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import java.util.regex.Pattern;

import static io.vertx.ext.auth.impl.Codec.base16Encode;
import static io.vertx.ext.web.common.HttpException.UNAUTHORIZED;
import static io.vertx.ext.web.handler.HttpException.UNAUTHORIZED;

/**
* @author <a href="mailto:plopes@redhat.com">Paulo Lopes</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.impl.RoutingContextInternal;

import static io.vertx.ext.web.common.HttpException.BAD_METHOD;
import static io.vertx.ext.web.common.HttpException.BAD_REQUEST;
import static io.vertx.ext.web.handler.HttpException.BAD_METHOD;
import static io.vertx.ext.web.handler.HttpException.BAD_REQUEST;

/**
* @author <a href="http://tfox.org">Tim Fox</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import io.vertx.ext.auth.jwt.JWTAuth;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.Session;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;
import io.vertx.ext.web.handler.JWTAuthHandler;
import io.vertx.ext.web.impl.RoutingContextInternal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.Session;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;
import io.vertx.ext.web.handler.OtpAuthHandler;
import io.vertx.ext.web.impl.OrderListener;
import io.vertx.ext.web.impl.RoutingContextInternal;

import static io.vertx.ext.web.common.HttpException.UNAUTHORIZED;
import static io.vertx.ext.web.handler.HttpException.UNAUTHORIZED;

/**
* @author <a href="mailto:pmlopes@gmail.com">Paulo Lopes</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.Session;
import io.vertx.ext.auth.common.UserContext;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;

public class UserContextImpl extends AbstractUserContext {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.vertx.ext.auth.properties.PropertyFileAuthentication;
import io.vertx.ext.auth.properties.PropertyFileAuthorization;
import io.vertx.ext.web.WebTestBase;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;
import io.vertx.ext.web.sstore.SessionStore;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.vertx.ext.auth.jwt.JWTAuth;
import io.vertx.ext.auth.jwt.JWTAuthOptions;
import io.vertx.ext.web.WebTestBase;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;
import io.vertx.ext.web.sstore.LocalSessionStore;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import io.vertx.ext.auth.authentication.Credentials;
import io.vertx.ext.auth.authentication.UsernamePasswordCredentials;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.common.HttpException;
import io.vertx.ext.web.handler.HttpException;
import org.junit.Test;

import static org.mockito.ArgumentMatchers.any;
Expand Down

0 comments on commit a73b457

Please sign in to comment.