mirror of
https://github.com/airlabspl/uptimemonitor.git
synced 2025-08-14 20:29:16 +02:00
initial commit
This commit is contained in:
29
handler/handler.go
Normal file
29
handler/handler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"uptimemonitor"
|
||||
"uptimemonitor/service"
|
||||
"uptimemonitor/store"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
Store *store.Store
|
||||
Secure bool
|
||||
}
|
||||
|
||||
func New(store *store.Store, service *service.Service, secure bool) *Handler {
|
||||
return &Handler{
|
||||
Store: store,
|
||||
Secure: secure,
|
||||
}
|
||||
}
|
||||
|
||||
func getUserFromRequest(r *http.Request) uptimemonitor.User {
|
||||
user, ok := r.Context().Value(userContextKey).(uptimemonitor.User)
|
||||
if !ok {
|
||||
return uptimemonitor.User{}
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
Reference in New Issue
Block a user