From bdb49be73456afc6b3da03d938e188f3c44fe6f4 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Tue, 13 Mar 2018 12:38:42 -0700 Subject: [PATCH] Added PROPFIND method Signed-off-by: Vishal Rana --- echo.go | 20 +++++++------- router.go | 79 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 53 insertions(+), 46 deletions(-) diff --git a/echo.go b/echo.go index 16c8d82d..713f005c 100644 --- a/echo.go +++ b/echo.go @@ -129,15 +129,16 @@ type ( // HTTP methods const ( - CONNECT = "CONNECT" - DELETE = "DELETE" - GET = "GET" - HEAD = "HEAD" - OPTIONS = "OPTIONS" - PATCH = "PATCH" - POST = "POST" - PUT = "PUT" - TRACE = "TRACE" + CONNECT = "CONNECT" + DELETE = "DELETE" + GET = "GET" + HEAD = "HEAD" + OPTIONS = "OPTIONS" + PATCH = "PATCH" + POST = "POST" + PROPFIND = "PROPFIND" + PUT = "PUT" + TRACE = "TRACE" ) // MIME types @@ -239,6 +240,7 @@ var ( OPTIONS, PATCH, POST, + PROPFIND, PUT, TRACE, } diff --git a/router.go b/router.go index cd91dc80..ff53da87 100644 --- a/router.go +++ b/router.go @@ -21,15 +21,16 @@ type ( kind uint8 children []*node methodHandler struct { - connect HandlerFunc - delete HandlerFunc - get HandlerFunc - head HandlerFunc - options HandlerFunc - patch HandlerFunc - post HandlerFunc - put HandlerFunc - trace HandlerFunc + connect HandlerFunc + delete HandlerFunc + get HandlerFunc + head HandlerFunc + options HandlerFunc + patch HandlerFunc + post HandlerFunc + propfind HandlerFunc + put HandlerFunc + trace HandlerFunc } ) @@ -225,22 +226,24 @@ func (n *node) findChildByKind(t kind) *node { func (n *node) addHandler(method string, h HandlerFunc) { switch method { - case GET: - n.methodHandler.get = h - case POST: - n.methodHandler.post = h - case PUT: - n.methodHandler.put = h - case DELETE: - n.methodHandler.delete = h - case PATCH: - n.methodHandler.patch = h - case OPTIONS: - n.methodHandler.options = h - case HEAD: - n.methodHandler.head = h case CONNECT: n.methodHandler.connect = h + case DELETE: + n.methodHandler.delete = h + case GET: + n.methodHandler.get = h + case HEAD: + n.methodHandler.head = h + case OPTIONS: + n.methodHandler.options = h + case PATCH: + n.methodHandler.patch = h + case POST: + n.methodHandler.post = h + case PROPFIND: + n.methodHandler.propfind = h + case PUT: + n.methodHandler.put = h case TRACE: n.methodHandler.trace = h } @@ -248,22 +251,24 @@ func (n *node) addHandler(method string, h HandlerFunc) { func (n *node) findHandler(method string) HandlerFunc { switch method { - case GET: - return n.methodHandler.get - case POST: - return n.methodHandler.post - case PUT: - return n.methodHandler.put - case DELETE: - return n.methodHandler.delete - case PATCH: - return n.methodHandler.patch - case OPTIONS: - return n.methodHandler.options - case HEAD: - return n.methodHandler.head case CONNECT: return n.methodHandler.connect + case DELETE: + return n.methodHandler.delete + case GET: + return n.methodHandler.get + case HEAD: + return n.methodHandler.head + case OPTIONS: + return n.methodHandler.options + case PATCH: + return n.methodHandler.patch + case POST: + return n.methodHandler.post + case PROPFIND: + return n.methodHandler.propfind + case PUT: + return n.methodHandler.put case TRACE: return n.methodHandler.trace default: