package id import ( "net/http" "go.mongodb.org/mongo-driver/bson/primitive" "github.com/go-chi/chi" ) func ParseFromRequest(r *http.Request) (*primitive.ObjectID, error) { id, err := primitive.ObjectIDFromHex(chi.URLParam(r, "id")) if err != nil { return nil, err } return &id, nil }