16
16
*
17
17
***************************************************************/
18
18
19
- // Package registry handles namespace management in Pelican ecosystem.
19
+ // Package registry handles namespace registration in Pelican ecosystem.
20
20
//
21
21
// - It handles the logic to spin up a "registry" server for namespace management,
22
22
// including a web UI for interactive namespace registration, approval, and browsing.
@@ -84,9 +84,7 @@ type TokenResponse struct {
84
84
Error string `json:"error"`
85
85
}
86
86
87
- /*
88
- Various auxiliary functions used for client-server security handshakes
89
- */
87
+ // Various auxiliary functions used for client-server security handshakes
90
88
type registrationData struct {
91
89
ClientNonce string `json:"client_nonce"`
92
90
ClientPayload string `json:"client_payload"`
@@ -301,7 +299,7 @@ func keySignChallengeCommit(ctx *gin.Context, data *registrationData, action str
301
299
return sysErr
302
300
}
303
301
304
- err = dbAddNamespace (ctx , data )
302
+ err = addNamespaceHandler (ctx , data )
305
303
if err != nil {
306
304
ctx .JSON (500 , gin.H {"error" : "The server encountered an error while attempting to add the prefix to its database" })
307
305
return errors .Wrapf (err , "Failed while trying to add to database" )
@@ -316,9 +314,7 @@ func keySignChallengeCommit(ctx *gin.Context, data *registrationData, action str
316
314
return nil
317
315
}
318
316
319
- /*
320
- Handler functions called upon by the gin router
321
- */
317
+ // Handler functions called upon by the gin router
322
318
func cliRegisterNamespace (ctx * gin.Context ) {
323
319
324
320
var reqData registrationData
@@ -490,7 +486,7 @@ func cliRegisterNamespace(ctx *gin.Context) {
490
486
}
491
487
}
492
488
493
- func dbAddNamespace (ctx * gin.Context , data * registrationData ) error {
489
+ func addNamespaceHandler (ctx * gin.Context , data * registrationData ) error {
494
490
var ns Namespace
495
491
ns .Prefix = data .Prefix
496
492
@@ -515,7 +511,7 @@ func dbAddNamespace(ctx *gin.Context, data *registrationData) error {
515
511
return nil
516
512
}
517
513
518
- func dbDeleteNamespace (ctx * gin.Context ) {
514
+ func deleteNamespaceHandler (ctx * gin.Context ) {
519
515
/*
520
516
A weird feature of gin is that wildcards always
521
517
add a preceding /. Since the URL parsing that happens
@@ -621,7 +617,7 @@ func cliListNamespaces(c *gin.Context) {
621
617
}
622
618
*/
623
619
624
- func dbGetAllNamespaces (ctx * gin.Context ) {
620
+ func getAllNamespacesHandler (ctx * gin.Context ) {
625
621
nss , err := getAllNamespaces ()
626
622
if err != nil {
627
623
ctx .JSON (http .StatusInternalServerError , gin.H {"error" : "server encountered an error trying to list all namespaces" })
@@ -644,7 +640,7 @@ func wildcardHandler(ctx *gin.Context) {
644
640
645
641
// Equivalent of group.GET("/getNamespace")
646
642
if path == "/getNamespace" {
647
- dbGetNamespace (ctx )
643
+ handleGetNamespace (ctx )
648
644
return
649
645
}
650
646
@@ -671,7 +667,7 @@ func wildcardHandler(ctx *gin.Context) {
671
667
ctx .String (http .StatusNotFound , "404 Not Found" )
672
668
}
673
669
674
- func dbGetNamespace (ctx * gin.Context ) {
670
+ func handleGetNamespace (ctx * gin.Context ) {
675
671
prefix := ctx .GetHeader ("X-Pelican-Prefix" )
676
672
if prefix == "" {
677
673
ctx .JSON (http .StatusBadRequest , gin.H {"error" : "X-Pelican-Prefix header required" })
@@ -694,10 +690,10 @@ func RegisterRegistryAPI(router *gin.RouterGroup) {
694
690
// routing if needed.
695
691
{
696
692
registryAPI .POST ("" , cliRegisterNamespace )
697
- registryAPI .GET ("" , dbGetAllNamespaces )
693
+ registryAPI .GET ("" , getAllNamespacesHandler )
698
694
699
695
// Handle everything under "/" route with GET method
700
696
registryAPI .GET ("/*wildcard" , wildcardHandler )
701
- registryAPI .DELETE ("/*wildcard" , dbDeleteNamespace )
697
+ registryAPI .DELETE ("/*wildcard" , deleteNamespaceHandler )
702
698
}
703
699
}
0 commit comments