Try generated app
These instructions only work if you answer YES to the question "generate hello resource example".
Still you will find information relevant for any RESTX app.
Launch the app
<your.main.package>.AppServer class in the src/main/java directory, and run it from your IDE as a regular Java application.
Alternatively, you can use the shell to run the app with
restx app run.
You should see something like this in your IDE console:
First contact: the admin web console
As the console invite you to do, open http://localhost:8080/api/@/ui/ in your browser.
It will first prompt for a user and password. The default user to use is
admin, and you should have provided the password during app scaffolding. If you don’t override the default password in your app, the default one is
juma. Check the security doc for details on restx security feature.
Once logged in, you should see the RESTX admin console home:
Then go to the API DOCS page, as you can see it’s listing several resources already available in your app:
The routes starting with `/@/` are used for the admin console.
This is a reserved path in RESTX, as long as you want to benefit from the admin console which is optional. To get rid of it you just need to remove dependencies on all the admin modules.
Now select the
/message resource, the generated documentation tells you that this resource takes a query parameter called who, of type String. Note also the example which gives you an example of request and corresponding response:
If the /message route is missing, double check your IDE setup, and especially the annotation processing settings.
Trying out the
Now you can try it out, use the
Try it out button at the top of the page, and you will be able to provide the desired value for the query parameter, and see the result:
RESTX by default uses md5 hashed password to avoid sending passwords in clear text.
This doesn't mean you don't need to secure your connection in production with HTTPS, and encrypt/hash passwords with salt when storing them in database. RESTX has very good support for that by the way.
To compute the md5 of your password RESTX shell provides a convenient `restx hash md5 [whatever]` command.
Since this is a GET request, you can also simply open the URL in your browser (in a browser where you are already authenticated): http://localhost:8080/api/message?who=restx
RESTX also supports HTTP Basic authentication, as soon as you provide the password md5 and not the password itself you should be able to use it conveniently with `curl` or `httpie`
Now go to the monitoring page in the console, you will get a page listing a set of elements which are monitored:
You have mainly 2 categories of elements monitored by default:
<BUILD> corresponds to instanciation of the components of your application. Most components being instantiated at startup time, this is useful to track which components is responsible for slowing down your app startup time. The time you see in the
max columns are in ms, and corresponds to the component instanciation, without taking into account its dependencies instanciation (so that it’s easier to track down components actually taking time to instanciate).
<HTTP> corresponds to HTTP requests handled by RESTX. The time indicated in the
max columns are in ms, and corresponds to the time spent to handle the request in RESTX. This does not take into accound HTTP container time (servlet container or other container).
Using the search box in the upper left you can easily filter lines based on the content of their
Label column, so if you want only
<HTTP> elements you just need to type
For instance you can search for
/message and you will see performance information for the
The generated app contains an integration test for the simple resource defined. You can launch it by opening the
<your.main.package>.rest.HelloResourceSpecTest class as a junit test.
You should see something like that:
Obviously you can also run the tests from your build tool. Both Maven and EasyAnt are supported out of the box, setting up other build tools should be really easy, RESTX is pure Java and tests are regular JUnit tests.
Open issues or submit pull requests if you want to get more build tools supported out of the box.
Now that you have tried the generated app, it’s time to understand its sources.