Skip to content

Commit

Permalink
Added PROPFIND method
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed Mar 13, 2018
1 parent 27b5253 commit bdb49be
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 38 deletions.
20 changes: 11 additions & 9 deletions echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -239,6 +240,7 @@ var (
OPTIONS,
PATCH,
POST,
PROPFIND,
PUT,
TRACE,
}
Expand Down
63 changes: 34 additions & 29 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)

Expand Down Expand Up @@ -225,45 +226,49 @@ func (n *node) findChildByKind(t kind) *node {

func (n *node) addHandler(method string, h HandlerFunc) {
switch method {
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 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 TRACE:
n.methodHandler.trace = h
}
}

func (n *node) findHandler(method string) HandlerFunc {
switch method {
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 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 TRACE:
return n.methodHandler.trace
default:
Expand Down

0 comments on commit bdb49be

Please sign in to comment.