package net.zephyrizing.http_server.handlers;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import net.zephyrizing.http_server.HttpRequest;
import net.zephyrizing.http_server.HttpResponse;
import net.zephyrizing.http_server.content.ContentProvider;
import net.zephyrizing.http_server.content.DirectoryContentProvider;
import net.zephyrizing.http_server.content.FileContentProvider;

public class FileSystemHandler implements Handler {
    private final Path root;

    public FileSystemHandler(Path root) {
        this.root = root;
    }

    @Override
    public HttpResponse handle(HttpRequest request) {
        HttpResponse response = HttpResponse.responseFor(request);
        response.setContent(getContentFor(Paths.get("/").relativize(request.path())));
        return response;
    }

    public ContentProvider getContentFor(Path path) {
        Path absolutePath = this.root.resolve(path);
        if (Files.isRegularFile(absolutePath)) {
            return new FileContentProvider(absolutePath);
        } else if (Files.isDirectory(absolutePath)) {
            return new DirectoryContentProvider(this.root, path);
        } else {
            return null;
        }
    }
}

@@ -172,16 +172,71 @@
 equest;%0A
+import net.zephyrizing.http_server.HttpRequest.Method;%0A
 import n
@@ -276,16 +276,17 @@
 sponse;%0A
+%0A
 import n
@@ -692,24 +692,74 @@
  request) %7B%0A
+        if (request.method() == Method.GET) %7B%0A    
         Http
@@ -813,16 +813,20 @@
 quest);%0A
+    
         
@@ -908,24 +908,28 @@
 ));%0A        
+ 
+   
 return respo
@@ -933,16 +933,68 @@
 sponse;%0A
+        %7D else %7B%0A            return null;%0A        %7D%0A
     %7D%0A%0A 

Make the FileHandler more specific