From d490f50d450b911d40c92e17acb4b319eae7d977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisendo=CC=88rfer?= Date: Mon, 6 May 2013 15:08:34 +0200 Subject: [PATCH] Comments and fixed status code --- src/http/data_store.go | 2 ++ src/http/handler.go | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/http/data_store.go b/src/http/data_store.go index 15a0c3d..9189fa1 100644 --- a/src/http/data_store.go +++ b/src/http/data_store.go @@ -31,6 +31,8 @@ func (s *DataStore) CreateFile(id string, size int64, meta map[string]string) er } defer file.Close() + // @TODO Refactor DataStore to support meta argument properly. Needs to be + // defined in tus protocol first. entry := logEntry{Meta: &metaEntry{ Size: size, ContentType: "", diff --git a/src/http/handler.go b/src/http/handler.go index 09b8e40..2ada4a3 100644 --- a/src/http/handler.go +++ b/src/http/handler.go @@ -66,7 +66,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - // example relPath results: "/", "/f81d4fae7dec11d0a765-00a0c91e6bf6", etc. + // example relPath results: "/", "/f81d4fae7dec11d0a76500a0c91e6bf6", etc. relPath := absPath[len(h.config.BasePath)-1:] // file creation request @@ -98,11 +98,17 @@ func (h *Handler) createFile(w http.ResponseWriter, r *http.Request) { return } + // @TODO: What happens if Final-Length is <= 0 + + // @TODO: Provide meta data + // @TODO: Make max finalLength configurable, reply with error if exceeded. + // This should go into the protocol as well. if err := h.store.CreateFile(id, finalLength, nil); err != nil { h.err(err, w, http.StatusInternalServerError) return } + w.WriteHeader(http.StatusCreated) w.Header().Set("Location", h.absUrl(r, "/"+id)) }