37 lines
1005 B
Go
37 lines
1005 B
Go
package server
|
|
|
|
import "net/http"
|
|
|
|
// authMiddleware check the authentication token before accessing to the resource
|
|
func (s *HTTPServer) authMiddleware(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
// TODO
|
|
})
|
|
}
|
|
|
|
// adminMiddleware check the role of the user before accessing to the resource
|
|
func (s *HTTPServer) adminMiddleware(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
// TODO
|
|
})
|
|
}
|
|
|
|
// uploadMiddleware check the upload key before allowing to upload a file
|
|
func (s *HTTPServer) uploadMiddleware(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
// TODO
|
|
})
|
|
}
|
|
|
|
func recoverMiddleware(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
defer func() {
|
|
err := recover()
|
|
if err != nil {
|
|
internalServerError(w, r)
|
|
}
|
|
}()
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|