--- a/src/main/scala/Filesystem.scala Wed Apr 04 22:31:39 2012 +0200
+++ b/src/main/scala/Filesystem.scala Wed Apr 04 23:53:09 2012 +0200
@@ -10,6 +10,7 @@
import Scalaz._
import scala.sys
+import java.nio.file.Files
class Filesystem(
baseDirectory: File,
@@ -95,6 +96,11 @@
case t => t.fail
}
+ def delete : Validation[Throwable, Unit]= try {
+ Files.delete(fileOnDisk.toPath).success
+ } catch {
+ case e: IOException => e.fail
+ }
}
}
--- a/src/main/scala/GraphCache.scala Wed Apr 04 22:31:39 2012 +0200
+++ b/src/main/scala/GraphCache.scala Wed Apr 04 23:53:09 2012 +0200
@@ -92,6 +92,8 @@
def save(model: Model) = throw new MethodNotSupportedException("not implemented")
def createDirectory(model: Model) = throw new MethodNotSupportedException("not implemented")
+
+ def delete = throw new MethodNotSupportedException("not implemented")
}
private def getUrl(u: URL) = {
--- a/src/main/scala/ReadWriteWeb.scala Wed Apr 04 22:31:39 2012 +0200
+++ b/src/main/scala/ReadWriteWeb.scala Wed Apr 04 23:53:09 2012 +0200
@@ -162,6 +162,10 @@
}
case POST(_) =>
BadRequest ~> ResponseString("Content-Type MUST be one of: " + Post.supportedAsString)
+ case DELETE(_) => {
+ for { _ <- r.delete failMap { t => NotFound ~> ResponseString("Error found"+t.toString)}
+ } yield NoContent
+ }
case _ => MethodNotAllowed ~> Allow("GET", "PUT", "POST")
}
res
--- a/src/main/scala/Resource.scala Wed Apr 04 22:31:39 2012 +0200
+++ b/src/main/scala/Resource.scala Wed Apr 04 23:53:09 2012 +0200
@@ -20,6 +20,7 @@
trait Resource {
def name: URL
def get(policy: CacheControl.Value = CacheControl.CacheFirst): Validation[Throwable, Model]
+ def delete: Validation[Throwable, Unit]
def save(model:Model):Validation[Throwable, Unit]
def createDirectory(model: Model): Validation[Throwable, Unit]
}