keyctl/pkg/api/v1/server/routes.go

77 lines
1.6 KiB
Go

// Copyright (C) 2023 Marius Schellenberger
package server
import (
"git.giftfish.de/ston1th/keyctl/pkg/api/types"
"git.giftfish.de/ston1th/keyctl/pkg/api/v1/schema"
"git.giftfish.de/ston1th/keyctl/pkg/core"
)
const (
keyID = schema.KeyPath + core.IDRoute
keyReqID = schema.KeyPath + core.IDRoute + core.AIDRoute
reqID = schema.ReqPath + core.IDRoute
accessID = schema.AccessPath + core.IDRoute
access = schema.AccessPath + core.HostRoute + core.UserRoute
accessAID = schema.AccessPath + core.HostRoute + core.UserRoute + core.AIDRoute
)
var Routes = []types.Route{
{
Path: schema.KeyPath,
Handler: local(keyListHandler),
Methods: []string{"GET"},
},
{
Path: schema.KeyPath,
Handler: local(newHandler),
Methods: []string{"POST"},
},
{
Path: keyID,
Handler: keyHandler,
Methods: []string{"GET"},
},
{
Path: keyReqID,
Handler: keyHandler,
Methods: []string{"GET"},
},
{
Path: keyID,
Handler: local(keyHandler),
Methods: []string{"DELETE"},
},
{
Path: schema.ReqPath,
Handler: local(reqListHandler),
Methods: []string{"GET"},
},
{
Path: reqID,
Handler: local(reqHandler),
Methods: []string{"PUT", "DELETE"},
},
// SSH
{
Path: accessID,
Handler: local(accessReqHandler),
Methods: []string{"PUT", "DELETE"},
},
{
Path: schema.AccessPath,
Handler: local(accessListHandler),
Methods: []string{"GET"},
},
{
Path: access,
Handler: accessHandler,
Methods: []string{"GET"},
},
{
Path: accessAID,
Handler: accessHandler,
Methods: []string{"GET"},
},
}