GithubHelp home page GithubHelp logo

noboomu / proteus Goto Github PK

View Code? Open in Web Editor NEW
185.0 185.0 18.0 26.67 MB

Proteus is a blazing fast minimalist Java web server framework built atop Undertow.

License: Apache License 2.0

Java 99.36% HTML 0.64%
api api-server high-performance http2 java jax-rs microservice microservice-framework mvc openapi reactive rest rest-api restful-api swagger undertow web-framework

proteus's People

Contributors

dheerajkhardwal avatar nich0s avatar noboomu avatar ratcashdev avatar seanmollet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

proteus's Issues

Problem with @Path with regex and @PathParam

I have a method:

@GET
@Path("{givenDate:[0-9]}")
public ServerResponse<Rates> givenDate(ServerRequest request, @PathParam("givenDate") String from) {
...

When I try to call the method, I get:

UT005071: Undertow request failed HttpServerExchange{ GET /v1/method/1 request {Accept=[application/json], Accept-Language=[en-US,en;q=0.5], Accept-Encoding=[gzip, deflate], DNT=[1], Origin=[http://localhost:8090], User-Agent=[Mozilla/5.0], Connection=[keep-alive], Referer=[http://localhost:8090/v1/openapi], Host=[localhost:8090]} response {Server=[proteus]}}
java.lang.IllegalArgumentException: Missing parameter givenDate
	at io.sinistral.proteus.server.Extractors.string(Extractors.java:397)
	at io.sinistral.proteus.controllers.handlers.CurrencyConvertRouteSupplier$2.handleRequest(CurrencyConvertRouteSupplier.java:56)
	at io.sinistral.example.wrappers.DummyWrapper$1.handleRequest(DummyWrapper.java:39)
	at io.undertow.server.handlers.accesslog.AccessLogHandler.handleRequest(AccessLogHandler.java:138)
	at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
	at io.sinistral.proteus.server.handlers.ServerDefaultHttpHandler.handleRequest(ServerDefaultHttpHandler.java:70)
	at io.undertow.server.session.SessionAttachmentHandler.handleRequest(SessionAttachmentHandler.java:68)
	at io.undertow.server.protocol.http2.Http2UpgradeHandler.handleRequest(Http2UpgradeHandler.java:102)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
	at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162)
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100)
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291)
	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
	at org.xnio.nio.QueuedNioTcpServer$1.run(QueuedNioTcpServer.java:129)
	at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:582)
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:466)
Caused by: java.lang.NullPointerException: null
	at io.sinistral.proteus.server.Extractors.string(Extractors.java:394)
	... 20 common frames omitted
java.lang.IllegalArgumentException: Missing parameter givenDate
	at io.sinistral.proteus.server.Extractors.string(Extractors.java:397) ~[proteus-core-0.3.7-SNAPSHOT.jar:na]
	at io.sinistral.proteus.controllers.handlers.CurrencyConvertRouteSupplier$2.handleRequest(CurrencyConvertRouteSupplier.java:56) ~[na:na]
	at io.sinistral.example.wrappers.DummyWrapper$1.handleRequest(DummyWrapper.java:39) ~[classes/:na]
	at io.undertow.server.handlers.accesslog.AccessLogHandler.handleRequest(AccessLogHandler.java:138) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.sinistral.proteus.server.handlers.ServerDefaultHttpHandler.handleRequest(ServerDefaultHttpHandler.java:70) ~[proteus-core-0.3.7-SNAPSHOT.jar:na]
	at io.undertow.server.session.SessionAttachmentHandler.handleRequest(SessionAttachmentHandler.java:68) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.undertow.server.protocol.http2.Http2UpgradeHandler.handleRequest(Http2UpgradeHandler.java:102) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136) ~[undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162) [undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100) [undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57) [undertow-core-2.0.15.Final.jar:2.0.15.Final]
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.8.Final.jar:3.3.8.Final]
	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291) [xnio-api-3.3.8.Final.jar:3.3.8.Final]
	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286) [xnio-api-3.3.8.Final.jar:3.3.8.Final]
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.8.Final.jar:3.3.8.Final]
	at org.xnio.nio.QueuedNioTcpServer$1.run(QueuedNioTcpServer.java:129) [xnio-nio-3.3.8.Final.jar:3.3.8.Final]
	at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:582) [xnio-nio-3.3.8.Final.jar:3.3.8.Final]
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:466) [xnio-nio-3.3.8.Final.jar:3.3.8.Final]
Caused by: java.lang.NullPointerException: null
	at io.sinistral.proteus.server.Extractors.string(Extractors.java:394) ~[proteus-core-0.3.7-SNAPSHOT.jar:na]
	... 20 common frames omitted

Please note that io.sinistral.proteus.server.Extractors.string(Extractors.java:394) is calling HttpServerExchange.getQueryParameters() and I suspect that the call should be HttpServerExchange.getPathParameters().

Something wrong with POM

I get this when I run the quickstart:

$ /bin/bash -e <(curl -fsSL https://raw.githubusercontent.com/noboomu/proteus-example/master/scripts/quickStart.sh)
Cloning into 'proteus-example'...
Warning: Permanently added the RSA host key for IP address '{removed}' to the list of known hosts.
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 226 (delta 0), reused 10 (delta 0), pack-reused 208
Receiving objects: 100% (226/226), 441.58 KiB | 4.80 MiB/s, done.
Resolving deltas: 100% (52/52), done.
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< io.sinistral:proteus-example >--------------------
[INFO] Building proteus-example 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.328 s
[INFO] Finished at: 2019-08-30T14:08:10-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project proteus-example: Could not resolve dependencies for project io.sinistral:proteus-example:jar:1.0.0: Failed to collect dependencies at io.sinistral:proteus-core:jar:0.4.1: Failed to read artifact descriptor for io.sinistral:proteus-core:jar:0.4.1: Failure to find io.sinistral:proteus-project:pom:0.4.1 in https://oss.sonatype.org/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of oss-sonatype has elapsed or updates are forced

Registering a Service with its own thread

Is it possible to register a Service that will spawn/use its own thread? As I see it the supported BaseService is using the AbstractIdleService which, according to the javadoc can't use its own thread.
Alternatively, if Proteus does not support this, is it possible to get to Undertow's builder? The idea is to poll messages from a queue (hence the thread that constantly checks for messages) and feeding it to undertow's websockets.

How to download file?

@GET
@Path("/downloadFile/{fileName}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public ServerResponse<ByteBuffer> downloadFile(ServerRequest request, @PathParam("fileName") final String fileName ) throws Exception
{
    String userDir = System.getProperty("user.dir");
    File file = new File(userDir + "/assets/" + fileName);
    ServerResponse serverResponse = new io.sinistral.proteus.server.ServerResponse();
    serverResponse.contentType("application/json;charset=UTF-8");
    serverResponse.addHeader("Content-Disposition", "attachment;filename=" + file.getName());
    serverResponse.addHeader("Content-Length", "" + file.length());
    return serverResponse.entity(ByteBuffer.wrap(Files.toByteArray(file))).applicationOctetStream();
}

Is it correct? :)

Guice configuration errors run proteus-example on ubuntu 16, oracle jdk 1.8

Exception in thread "main" com.google.inject.ConfigurationException: Guice configuration errors:

  1. No implementation for java.lang.String annotated with @com.google.inject.name.Named(value=security.callbackPath) was bound.
    Did you mean?
  • java.lang.String annotated with @com.google.inject.name.Named(value=user.country)
  • java.lang.String annotated with @com.google.inject.name.Named(value=openapi.info.version)
  • java.lang.String annotated with @com.google.inject.name.Named(value=application.fallbackHandler)
    107 more bindings with other annotations.
    while locating java.lang.String annotated with @com.google.inject.name.Named(value=security.callbackPath)
    for field at io.sinistral.example.modules.SecurityModule.callbackPath(SecurityModule.java:46)
    while locating io.sinistral.example.modules.SecurityModule
    ......
    4 errors
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1075)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1034)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1086)
    at io.sinistral.proteus.ProteusApplication.lambda$start$0(ProteusApplication.java:146)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at io.sinistral.proteus.ProteusApplication.start(ProteusApplication.java:146)
    at io.sinistral.example.ExampleApplication.main(ExampleApplication.java:45)

bindInterceptor cannot work

hi,
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Names.named("log")), new LoggerMethodInterceptor());

@Named("log")
public String get() {
    return "hello";
}

Quickstart doesn't work

Getting DependencyResolutionException when attempting to run the quickstart script, full logs as below:

[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< io.sinistral:proteus-example >--------------------
[INFO] Building proteus-example 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.pac4j:undertow-pac4j:jar:3.0.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.011 s
[INFO] Finished at: 2020-05-26T23:59:52-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project proteus-example: Could not resolve dependencies for project io.sinistral:proteus-example:jar:1.0.0: Failure to find org.pac4j:undertow-pac4j:jar:3.0.0-SNAPSHOT in https://oss.sonatype.org/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of oss-sonatype has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Any help is appreciated

Gradle support

Most maven projects can be imported with Gradle with no issues. However, this one fails as proteus-project artifact is missing in maven (Gradle scans parent project from pom.xml of the main dependency). Could you please solve this issue?

> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve io.sinistral:proteus-core:0.4.2.
     Required by:
         project :
      > Could not resolve io.sinistral:proteus-core:0.4.2.
         > Could not parse POM https://repo.maven.apache.org/maven2/io/sinistral/proteus-core/0.4.2/proteus-core-0.4.2.pom
            > Could not find io.sinistral:proteus-project:0.4.2.
              Searched in the following locations:
                - https://repo.maven.apache.org/maven2/io/sinistral/proteus-project/0.4.2/proteus-project-0.4.2.pom
              If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.


There is no pom for proteus-project in maven as far as I can say in the given link or anywhere else in the repo.

Reactor 3 integration?

Any plans to implement reactive? Jooby has a module (although based on Reactor 2.5).

I added this for Reactor 3, curious if something similar is possible with proteus?

    fun reactor(): Route.Mapper<Any> = Route.Mapper.create("reactor") { value ->
      when (value) {
        is Mono<*> -> Deferred { deferred ->
          value
            .doOnError { deferred.reject(it) }
            .doOnCancel { deferred.reject(Exception("cancelled")) }
            .subscribe { deferred.resolve(it) }
        }
        else -> value
      }
    }
  }

io.sinistral:proteus-project pom cannot be found in Maven repository

Trying to build a project with the following dependency:

io.sinistral
proteus-core
0.4.2

build is failed with the error: Could not resolve dependencies for project io.sinistral:proteus-example:jar:1.0.0: Failed to collect dependencies at io.sinistral:proteus-core:jar:0.4.2: Failed to read artifact descriptor for io.sinistral:proteus-core:jar:0.4.2: Could not find artifact io.sinistral:proteus-project:pom:0.4.2 in maven (https://repo1.maven.org/maven2/) -> [Help 1]

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.