/
dimamir
/
rill
Обзор
Документация
Войти
/
dimamir
/
rill
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
runtime/pkg/middleware/request.go
22 строки
552 B
Benjamin Egelund-Müller
Util for better HTTP error handling (#4220)
01 мар 2024, 13:55
Не верифицирован
01 мар 2024, 13:55
41dcbe7
Код
Авторство
О чём код?
package middleware import ( "net/http" "github.com/rilldata/rill/runtime/pkg/httputil" ) type CheckFunc func(req *http.Request) error // Check is a middleware that only calls the next handler if the checkFn succeeds. // If the checkFn fails, the error is written to the response as per the behavior of httputil.Handler. func Check(checkFn CheckFunc, next http.Handler) httputil.Handler { return func(w http.ResponseWriter, r *http.Request) error { if err := checkFn(r); err != nil { return err } next.ServeHTTP(w, r) return nil } }