Skip to content

Commit

Permalink
add WebDAV support(labstack#1610)
Browse files Browse the repository at this point in the history
Signed-off-by: yixy <youzhilane01@gmail.com>
  • Loading branch information
yixy committed May 4, 2022
1 parent 6df1c35 commit dc4c0bd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
14 changes: 14 additions & 0 deletions echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ const (
PROPFIND = "PROPFIND"
// REPORT Method can be used to get information about a resource, see rfc 3253
REPORT = "REPORT"
// RFC 4918: HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)
// https://tools.ietf.org/html/rfc4918
MKCOL = "MKCOL"
COPY = "COPY"
MOVE = "MOVE"
LOCK = "LOCK"
UNLOCK = "UNLOCK"
PROPPATCH = "PROPPATCH"
)

// Headers
Expand Down Expand Up @@ -274,6 +282,12 @@ var (
http.MethodPut,
http.MethodTrace,
REPORT,
MKCOL,
COPY,
MOVE,
LOCK,
UNLOCK,
PROPPATCH,
}
)

Expand Down
30 changes: 30 additions & 0 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ type (
put HandlerFunc
trace HandlerFunc
report HandlerFunc
mkcol HandlerFunc
copy HandlerFunc
move HandlerFunc
lock HandlerFunc
unlock HandlerFunc
proppatch HandlerFunc
allowHeader string
}
)
Expand Down Expand Up @@ -371,6 +377,18 @@ func (n *node) addHandler(method string, h HandlerFunc) {
n.methodHandler.trace = h
case REPORT:
n.methodHandler.report = h
case MKCOL:
n.methodHandler.mkcol = h
case COPY:
n.methodHandler.copy = h
case MOVE:
n.methodHandler.move = h
case LOCK:
n.methodHandler.lock = h
case UNLOCK:
n.methodHandler.unlock = h
case PROPPATCH:
n.methodHandler.proppatch = h
}

n.methodHandler.updateAllowHeader()
Expand Down Expand Up @@ -405,6 +423,18 @@ func (n *node) findHandler(method string) HandlerFunc {
return n.methodHandler.trace
case REPORT:
return n.methodHandler.report
case MKCOL:
return n.methodHandler.mkcol
case COPY:
return n.methodHandler.copy
case MOVE:
return n.methodHandler.move
case LOCK:
return n.methodHandler.lock
case UNLOCK:
return n.methodHandler.unlock
case PROPPATCH:
return n.methodHandler.proppatch
default:
return nil
}
Expand Down

0 comments on commit dc4c0bd

Please sign in to comment.