summaryrefslogtreecommitdiff
path: root/app/middleware/require_user.go
blob: d0d53554331c0b275cb3e4f1ff64bf75fc55a3bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package middleware

import (
	"net/http"
)

func RequireUser() func(http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			if IsLoggedIn(r) {
				next.ServeHTTP(w, r)
			} else {
				w.WriteHeader(http.StatusNotFound)
			}
		})
	}
}