go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/nodes/pkg/controller/utils.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package controller
     9  
    10  import (
    11  	"github.com/wcharczuk/go-incr"
    12  	"go.charczuk.com/sdk/uuid"
    13  	"go.charczuk.com/sdk/web"
    14  )
    15  
    16  func getRouteIdentifier(r web.Context, paramName string) (id incr.Identifier, err error) {
    17  	var rawNodeID string
    18  	rawNodeID, err = web.RouteValue[string](r, paramName)
    19  	if err != nil {
    20  		return
    21  	}
    22  	return incr.ParseIdentifier(rawNodeID)
    23  }
    24  
    25  func getNodeID(r web.Context) (id incr.Identifier, err error) {
    26  	return getRouteIdentifier(r, "id")
    27  }
    28  
    29  func getGraphID(r web.Context) (id uuid.UUID, err error) {
    30  	return web.RouteValue[uuid.UUID](r, "graph_id")
    31  }