package org.yamcs.http;

import org.yamcs.logging.Log;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.FullHttpRequest;

public abstract class Handler extends SimpleChannelInboundHandler<FullHttpRequest> {

    private static final Log log = new Log(Handler.class);

    public abstract void handle(HandlerContext ctx);

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest msg) throws Exception {
        try {
            String contextPath = ctx.channel().attr(HttpRequestHandler.CTX_CONTEXT_PATH).get();
            handle(new HandlerContext(contextPath, ctx, msg));
        } catch (Throwable t) {
            if (!(t instanceof HttpException)) {
                t = new InternalServerErrorException(t);
            }

            HttpException e = (HttpException) t;
            if (e.isServerError()) {
                log.error("Responding '{}': {}", e.getStatus(), e.getMessage(), e);
            } else {
                log.warn("Responding '{}': {}", e.getStatus(), e.getMessage());
            }
            HttpRequestHandler.sendPlainTextError(ctx, msg, e.getStatus());
        }
    }
}

@@ -344,24 +344,77 @@
 er.class);%0A%0A
+    // TODO make abstract once plugins have migrated%0A
     public a
@@ -407,24 +407,27 @@
 d%0A    public
+ /*
  abstract vo
@@ -423,16 +423,19 @@
 abstract
+ */
  void ha
@@ -462,56 +462,129 @@
 ctx)
-;%0A%0A    @Override%0A    prot
+ %7B%0A    %7D%0A%0A    /**%0A     * Implement %7B@link #handle(HandlerContext)%7D instead%0A     */%0A    @Depr
 ec
+a
 ted
+%0A    public
  void 
-c
 han
-nelRead0
+dle
 (Cha
@@ -632,45 +632,10 @@
 sg) 
-throws Exception %7B%0A        try %7B%0A    
+%7B%0A
     
@@ -730,20 +730,16 @@
         
-    
 handle(n
@@ -777,24 +777,188 @@
 ctx, msg));%0A
+    %7D%0A%0A    @Override%0A    protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest msg) throws Exception %7B%0A        try %7B%0A            handle(ctx, msg);%0A
         %7D ca

Add deprecation path for Handler signature change