All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.jdisc.handler.AbstractRequestHandler Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.handler;

import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.Response;

/**
 * 

This class provides an abstract {@link RequestHandler} implementation with reasonable defaults for everything but * {@link #handleRequest(Request, ResponseHandler)}.

* *

A very simple hello world handler could be implemented like this:

*
 * class HelloWorldHandler extends AbstractRequestHandler {
 *
 *     @Override
 *     public ContentChannel handleRequest(Request request, ResponseHandler handler) {
 *         ContentWriter writer = ResponseDispatch.newInstance(Response.Status.OK).connectWriter(handler);
 *         try {
 *             writer.write("Hello World!");
 *         } finally {
 *             writer.close();
 *         }
 *         return null;
 *     }
 * }
 * 
* * @author Simon Thoresen Hult */ public abstract class AbstractRequestHandler extends com.yahoo.jdisc.AbstractResource implements RequestHandler { @Override public void handleTimeout(Request request, ResponseHandler responseHandler) { Response.dispatchTimeout(responseHandler); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy