This commit is contained in:
ston1th 2023-03-21 01:00:13 +01:00
commit 05a68df896
15 changed files with 158 additions and 135 deletions

View file

@ -4,7 +4,6 @@ package types
import (
"sync"
"time"
"git.giftfish.de/ston1th/keyctl/pkg/key"
"golang.org/x/exp/maps"
@ -17,7 +16,8 @@ type ApprovalMap map[string]Approval
type Approver struct {
// protects m
mu sync.RWMutex
m ApprovalMap
m ApprovalMap
}
func NewApprover() *Approver {
@ -39,10 +39,9 @@ func (a *Approver) New(id, name, ip string) (aid string, err error) {
return
}
a.m[aid] = Approval{
ID: id,
Name: name,
IP: ip,
Created: time.Now().Unix(),
ID: id,
Name: name,
IP: ip,
}
return
}
@ -77,11 +76,10 @@ func (a *Approver) Update(aid string, s Status) {
}
type Approval struct {
ID string
Name string
IP string
Created int64
Status Status
ID string
Name string
IP string
Status Status
}
type Status int

View file

@ -15,8 +15,8 @@ import (
)
type ContextData struct {
DB *db.DB
Approver *Approver
DB *db.DB
}
func NewContext(w http.ResponseWriter, r *http.Request, data *ContextData, log logr.Logger) *Context {
@ -84,9 +84,8 @@ func (c *Context) ClientIP() (host string) {
}
// Var returns the given url variable
func (c *Context) Var(name string) (ret string) {
ret, _ = mux.Vars(c.Request)[name]
return
func (c *Context) Var(name string) string {
return mux.Vars(c.Request)[name]
}
func (c *Context) log() {