Quantcast
Channel: Ratpack – JDriven
Browsing all 38 articles
Browse latest View live

Ratpacked: Register Renderer For A List Of Objects

When we use the render method in our Ratpack application then Ratpack will use the type of the object we want to render to find an appropriate renderer. Some renderers are built-in, like a Promise or...

View Article



Ratpacked: Respond To Custom MIME Types

In Ratpack we can use the byContent method on the Context object to send different responses based on the requested MIME type from the client. There is already support for application/json,...

View Article

Ratpacked: Execute Code On Start and Stop Application Lifecycle Events

Ratpack has the ratpack.server.Service interface with the methods onStart and onStop. If we write an implementation class for the Service interface and register it with the Ratpack registry, then...

View Article

Ratpacked: Using Mapped Diagnostic Context (MDC) Logging

The logging framework SLF4J supports Mapped Diagnostic Context (MDC). With MDC we can use a logging context that can be identified by something unique. This is useful, because then we can distinguish...

View Article

Ratpacked: Implicit Registry Retrieval With InjectionHandler

If we write our own handler class it is not so difficult to get objects from the registry and use them in the code. In our handler we have a handle method and we get a Context object as argument. …...

View Article


Ratpacked: Execute Handlers Based On Accept Header

A client of our Ratpack application can send a HTTP Accept header to indicate the type of response the client expects or can handle. We can restrict our application to certain types with the accepts...

View Article

Ratpacked: Add Common Handlers Via The Registry

In our Ratpack application we can have handlers that need to be invoked for every request. For example the handler needs to set a response header and will use the Context.next() method to continue with...

View Article

Ratpacked: Add Chains Via Registry

In a previous blog post we learned how to use HandlerDecorator.prepend to add common handlers via the registry in our application. The type of handlers suitable for this approach were handlers that had...

View Article


Ratpacked: Tapping In On A Promise

We can use the wiretap method of the Promise interface to listen in on results. We write an Action implementation which has the result of a Promise encapsulated in a Result object. The wiretap method...

View Article


Ratpacked: Getting Multiple Objects With Same Type From Registry

To get objects from the registry or context we specify the type of the object we want. Ratpack will find the object(s) that match the given type. If we use the get method then the last object added to...

View Article

Ratpacked: Searching Objects In The Registry

In a previous post we learned about the get and getAll methods to get objects from the registry. Ratpack also provides the first method to get objects from the registry. This method accepts a Function...

View Article

Ratpacked: Using Database As Custom Configuration Source

We learned about externalised configuration in a previous blog post. Ratpack provides support out of the box for several formats and configuration sources. For example we can use files in YAML,...

View Article

Ratpacked: Customising Renderers With Decorators

When we use the Context.render method Ratpack’s rendering mechanism kicks in. The type of the argument we pass to the render method is used to look up the correct renderer. The renderer implements the...

View Article


Ratpacked: Different Base Directory With Marker File

To set the base directory for serving static files in a Ratpack application we can use the baseDir method of the ServerConfigBuilder class. We must provide a Path or File to this method. If we want to...

View Article

Ratpacked: Running Ratpack In Groovy Console

It is actually very easy to run a Ratpack application in the Groovy Console. The Groovy Console is a GUI application that is distributed with Groovy and allows us to write and run Groovy scripts. We...

View Article


Ratpacked: Debugging Application Defined Using Groovy DSL In IntelliJ IDEA

When we want to debug our Ratpack application written in Java we can simply use the Debug action on the main application class. When we described the application with the Groovy DSL we must add a...

View Article

Ratpacked: Running With LiveReload Using Gradle

When we develop our Ratpack application using Gradle we can use the continuous build feature of Gradle. If we make a change in a source file then our Ratpack application is automatically restarted. It...

View Article


Ratpacked: Using Spring As Component Registry

Usually in our Ratpack application we use a registry to store components that we want to use in our application code. The calling code for the registry doesn’t need to know how the registry is...

View Article

Ratpacked: Using Multiple DataSources

Recently on our project where we use Ratpack we had to get data from different databases in our Ratpack application. We already used the HikariModule to get a DataSource to connect to one database....

View Article

Ratpacked: Revisited Using Multiple DataSources

In a previous post we learned how to add an extra DataSource to our Ratpack application. At that time on the Ratpack Slack channel there was a discussion on this topic and Danny Hyun mentioned an idea...

View Article
Browsing all 38 articles
Browse latest View live




Latest Images