 
     /// The running HTTP server listening port
     public var port: UInt? {
-        get {
-            return webServer.port
-        }
+        get { return webServer.port }
     }
 
     /// The base URL of the server
     public var baseURL: URL? {
-        get {
-            return webServer.serverURL
-        }
-    }
+        get { return webServer.serverURL }
+    }
+
+    // MARK: - Public methods
 
     public init?() {
-        GCDWebServer.setLogLevel(0)
+        #if DEBUG
+            let port = 8080
+
+            GCDWebServer.setLogLevel(0)
+        #else
+            // Default: random port
+            let port = 0
+
+            GCDWebServer.setLogLevel(3)
+        #endif
+
         webServer = GCDWebServer()
         do {
-            #if DEBUG
-                // Debug
-                let port = 8080
-            #else
-                // Default: random port
-                let port = 0
-            #endif
-            try webServer.start(options: [
-                GCDWebServerOption_Port: port,
-                GCDWebServerOption_BindToLocalhost: true])
+            try webServer.start(options: [GCDWebServerOption_Port: port,
+                                          GCDWebServerOption_BindToLocalhost: true])
         } catch {
             NSLog("Failed to start the HTTP server: \(error)")
             return nil
         }
     }
 
-    /**
-     Add an EPUB container to the list of EPUBS being served.
-
-     - parameter container: The EPUB container of the publication
-     - parameter endpoint: The URI prefix to use to fetch assets from the publication `/{prefix}/{assetRelativePath}`
-     */
+
+    /// Add an EPUB container to the list of EPUBS being served.
+    ///
+    /// - Parameters:
+    ///   - container: The EPUB container of the publication
+    ///   - endpoint: The URI prefix to use to fetch assets from the publication
+    ///               `/{prefix}/{assetRelativePath}`
+    /// - Throws: `EpubServerError.epubParser`
     public func addEpub(container: Container, withEndpoint endpoint: String) throws {
         let parser: EpubParser
+        let publication: Publication
 
         guard containers[endpoint] == nil else {
             // FIXME: Mabe throw instead? Is that fine to just return? Tocheck

    case epubParser(underlayingError: Error)
}

/**
 The HTTP server for the publication's manifests and assets
 */
open class EpubServer {

    /// The HTTP server


     - parameter prefix: The URI prefix associated with the container (by `addEpub`)
     */
    public func removeEpub(withEndpoint endpoint: String) {
        if containers[endpoint] != nil {
            containers[endpoint] = nil
            publications[endpoint] = nil
            // TODO: remove handlers
        }
    }

    // MARK: - Internal methods

    /// Append a link to self in the given Publication links
    ///
    /// - Parameters:
    ///   - publication: The targeted publication.
    ///   - endPoint: The URI prefix to use to fetch assets from the publication.
    internal func addSelfLinkTo(publication: Publication, endpoint: String) {
        guard let baseURL = baseURL else {
            return
        }
        let manifestPath = "\(endpoint)/manifest.json"
        let publicationURL = baseURL.appendingPathComponent(manifestPath,
                                                            isDirectory: false)
        let link = Link(href: publicationURL.absoluteString,
                        typeLink: "application/webpub+json", rel: "self")

        publication.links.append(link)
    }

}
