Hey folks, i've actually been trying to integrate ...
# help
k
Hey folks, i've actually been trying to integrate cerbos with an http server in Golang. here are a few things about my code: ā€¢ it has 2 routes ā€¢ a user & post database (in-memory) ā€¢ an auth middleware You can find the entire code here. (P.S pls ignore the coding style as i'm a beginner in Go and just trying to understand the cerbos integration workflow šŸ™‚) If you see my implementation, i'm not really sure what to populate as a resource id while defining a new resource object:
Copy code
resource := cerbos.NewResource("posts", )
Apart from this, if you could pls guide me in the right direction regarding my rest of the implementation, that would mean a lot Thanks
s
Hi Kunal šŸ‘‹ The resource ID is an arbitrary, unique ID specific to each instance of your resource. It's specific to your use case. If you reason about it as a unique ID column for a table in your database, with rows representing instances of the particular resource, you're on the right track simple smile. It'll probably map 1:1 with that. With regards to the overall implementation, have you checked out our REST API demo? It's a thorough and detailed implementation of what you're building -- might be helpful as a reference point.
k
So, from what i understand & pls correct me if i'm wrong - referring to my database right now, i've got 2 posts defined:
Copy code
var posts = []Post{
	{
		Id:      "3123",
		Title:   "Kubernetes API Guide",
		Summary: "Covers the fundamental aspects of K8s api",
		UserId:  2,
		Flagged: false,
	},
	{
		Id:      "4636",
		Title:   "Golang Basics 101",
		Summary: "Covers the basics of Golang",
		UserId:  1,
		Flagged: false,
	},
}
So, if the resource id is basically a unique id which represents an entire resource, for instance, if resource id = 1, that means we are talking about the 1st post:
Copy code
{
		Id:      "3123",
		Title:   "Kubernetes API Guide",
		Summary: "Covers the fundamental aspects of K8s api",
		UserId:  2,
		Flagged: false,
	},
Is this the correct way of seeing this?
Sure! I'll have a look at the implementation and try to understand. Thanks for sharing
Oops! did the message get deleted šŸ˜ž
c
Hey, Cerbos requires a resource ID to help identify resources uniquely. When you are creating a new resource it's common to not know what the ID is because it hasn't been persisted yet. In those cases, our recommendation is to use a placeholder ID such as
NEW
.
āœ… 1
k
Gotcha! thanks for sharing