                 log(level: .error, "The request received is nil.")
                 return GCDWebServerErrorResponse(statusCode: 500)
             }
-//            guard let path = request.path else {
-//                log(level: .error, "The request's path to the ressource is empty.")
-//                return GCDWebServerErrorResponse(statusCode: 500)
-//            }
+            //            guard let path = request.path else {
+            //                log(level: .error, "The request's path to the ressource is empty.")
+            //                return GCDWebServerErrorResponse(statusCode: 500)
+            //            }
             // Remove the prefix from the URI.
             let relativePath = request.path.substring(from: request.path.index(endpoint.endIndex, offsetBy: 2))
             let resource = publication.resource(withRelativePath: relativePath)

            request: GCDWebServerRequest.self,
            processBlock: manifestHandler)

        // FIXME: Add the handler for the resources OPTIONS
        //         webServer.addHandler(
        //         forMethod: "OPTIONS",
        //         pathRegex: "/\(endpoint)/.*",
        //         request: GCDWebServerRequest.self,
        //         processBlock: { request in
        //
        //         guard let path = request?.path else {
        //         Log.error?.message("no path in options request")
        //         return GCDWebServerErrorResponse(statusCode: 500)
        //         }
        //
        //         Log.debug?.message("options request \(path)")
        //
        //         return GCDWebServerDataResponse()
        //         })

        log(level: .info, "Publication at \(endpoint) has been successfully added.")
    }

    public func remove(_ publication: Publication) {

            // TODO: Check if we can use unix socket instead of tcp.
            //       Check if it's supported by WKWebView first.
            try webServer.start(options: [GCDWebServerOption_Port: port,
                                          GCDWebServerOption_BindToLocalhost: true/*,
                 GCDWebServerOption_AutomaticallySuspendInBackground: false*/])
        } catch {
            log(level: .error, "Failed to start the HTTP server.")
            logValue(level: .error, error)
            return nil
        }
        addSpecialResourcesHandlers()
    }

    // To be called after leaving background.
    public func reloadHandlers() throws {
        // Clean all existing handlers, if any.
        webServer.removeAllHandlers()
        // Add the handlers for the static resources.
        addSpecialResourcesHandlers()
        // Add the handlers for the publications stored in the pubBoxes.
        for (endpoint, pubBox) in pubBoxes {
            do {
                try addResourcesHandler(for: pubBox, at: endpoint)
            } catch {
                throw PublicationServerError.fetcher(underlyingError: error)
            }
            addManifestHandler(for: pubBox, at: endpoint)
        }
    }

    // Add handlers for the css/js resources.
    public func addSpecialResourcesHandlers() {
        func styleRessourcesHandler(request: GCDWebServerRequest?) -> GCDWebServerResponse? {
            guard let request = request else {
                return GCDWebServerResponse(statusCode: 404)
            }
            let filename = request.path
            let resourceName = (filename as NSString).deletingPathExtension.lastPathComponent

            if let styleUrl = Bundle(for: ContentFiltersEpub.self).url(forResource: resourceName, withExtension: "css"),
                let data = try? Data.init(contentsOf: styleUrl)
            {
                let response = GCDWebServerDataResponse(data: data, contentType: "text/css")

                return response
            } else {
                return GCDWebServerResponse(statusCode: 404)
            }
        }
        /// Handler for Style resources.
        webServer.addHandler(forMethod: "GET",
                             pathRegex: "/styles/*",
                             request: GCDWebServerRequest.self,
                             processBlock: styleRessourcesHandler)

        func scriptRessourcesHandler(request: GCDWebServerRequest?) -> GCDWebServerResponse? {
            guard let request = request else {
                return GCDWebServerResponse(statusCode: 404)
            }
            let filename = request.path
            let resourceName = (filename as NSString).deletingPathExtension.lastPathComponent

            if let scriptUrl = Bundle(for: ContentFiltersEpub.self).url(forResource: resourceName, withExtension: "js"),
                let data = try? Data.init(contentsOf: scriptUrl)
            {
                let response = GCDWebServerDataResponse(data: data, contentType: "text/javascript")

                return response
            } else {
                return GCDWebServerResponse(statusCode: 404)
            }
        }
        /// Handler for JS resources.
        webServer.addHandler(forMethod: "GET",
                             pathRegex: "/scripts/*",
                             request: GCDWebServerRequest.self,
                             processBlock: scriptRessourcesHandler)
    }

    /// Add a publication to the server. Also add it to the `pubBoxes`
    ///
    /// - Parameters:
