What functors are classified by slices of $\infty$-categories? Suppose I have a functor $f\colon C\to D$ between $\infty$-categories (I'll assume $C$ and $D$ are small.)  Then I can form the slice categories and restriction functors
$$
D_{f/}\to D\qquad \text{and} \qquad D_{/f}\to D.
$$
These maps are left fibrations and right fibrations, respectively.  By the theory of "straightening/unstraightening", these fibrations are classified by certain functors
$$
D\to \mathcal{S} \qquad\text{and} \qquad D^{\mathrm{op}} \to \mathcal{S}
$$
to the $\infty$-category $\mathcal{S}$ of $\infty$-groupoids.  This raises the question:
Q.  What are these functors?
Actually, it's pretty clear what the answer should be:
A.  They are inverse limits of (co)representable functors.
Explicitly, we should be able to describe these functors by
$$
d\mapsto \mathrm{lim}_{c\in C^{\mathrm{op}}}\operatorname{Map}_D(f(c),d)
\qquad \text{and}\qquad
d\mapsto \mathrm{lim}_{c\in C}\operatorname{Map}_D(d,f(c))
$$
respectively.  In the 1-categorical analogue this an elementary argument.  The case of $C=1$ (slices over objects, corresponding to (co)representable functors) is "well-known" (see 5.8 of Cisinski's Higher categories and homotopical algebra).
So my real question is:
Q'.  What is a proof or reference for this fact?
 A: I like Maxime's argument better, but here's another.
As you say, the case when $C=\bullet$ is well-known. But we can reduce to that case! The map $D_{/f} \to D$ is pulled back from $\mathsf{Fun}(C, D)_{/f} \to \mathsf{Fun}(C,D)$ along the diagonal map $D \to \mathsf{Fun}(C,D)$. Under (un)straightening, pulling back corresponds to precomposition, and the functor on $\mathsf{Fun}(C,D)$ represented by $f$ restricts to the functor you described.
A: Here's a sketch of a proof :

Lemma: For a left fibration $p: A\to B$, the functor it classifies $B\to \mathcal S$ is given by $p_!(*)$, where $p_! : Fun(A,\mathcal S)\to Fun(B,\mathcal S)$ is left Kan extension.

Proof: Note that $Fun(A,\mathcal S)$ is equivalent to the full subcategory of $Cat_\infty/A$ on left fibrations, similarly for $B$, and the pullback functor $p^*: Cat_\infty/B\to Cat_\infty/A$ restricts to the precomposition functor on functor categories. But the left adjoint to $p^*$ on these slice categories is postcomposition by $p$, and the full subcategories on left fibrations are stable under this postcomposition because $p$ is itself a left fibration. It follows that $p_!$ is given by postcomposition at the level of fibrations.
Moreover, the constant $*$-valued functor on $A$ classifies $A\to A$, so that postcomposition by $p$ sends this to $A\to B$, so $p_!(*)$ is the image of that functor.

$D_{f/}$ classifies the functor you suggested.

Proof: Apply the lemma to $p: D_{f/}\to D$, to get that the classified functor is $p_!(*)$. On objects, this is given by $d\mapsto \mathrm{colim}_{(D_{f/})_{/d}}*$.
Now the $\infty$-category $(D_{f/})_{/d}$ is weakly equivalent to the mapping space $map(f,\Delta(d))$ in $Fun(C,D)$, so this colimit is given by this mapping space, which can be described by your limit.
The case of right fibrations is dual.
ADDED later : maybe it'd be good to have an argument for my weak equivalence claim. $\{id_d\}\to D_{/d}$ is cofinal, and $D_{f/}\to D$ is a left fibration, so pullback along it preserves cofinality (4.4.11. in Cisinski's book, although he uses "final" for what I call "cofinal"), in particular the fiber of $D_{f/}\to D$ over $\{id_d\}$ (the mapping space I mentioned) is cofinal in the pullback $(D_{f/})_{/d}$, which of course implies the claim about weak equivalence.
EDIT 2 : Here's how to see from the above paragraph that this is actually a functorial description: $\{id_d\}\to D_{/d}$ is lax natural in $d$, and therefore so is $(D_{f/})_{/d}\times_{D_{/d}} \{id_d\}\to (D_{f/})_{/d}$.
Now, the claim was that this second map is cofinal, so in particular, it induces an equivalence (which is of course still natural in $d$) between the "geometric realizations" (I'm not sure anymore what the standard name is for the left adjoint $Cat_\infty\to\mathcal S$); and on geometric realizations we can change from "lax natural" to "natural". Moreover, almost by definition, the LHS of this map is $map(f,\Delta(d))$ as a functor of $d$, not just pointwise.
The final claim is, of course, that $\mathrm{colim}_A *$ is the weak homotopy type of $A$, again naturally in $A$.
A: Let $\mathcal{S}$ denote the $\infty$-category of small spaces. For a small $\infty$-category $A$ and its object $a\in A$, I will write $A(-,a):A^\mathrm{op}\to\mathcal{S}$ for the presheaf represented by $a$. I will also write $\widehat{\mathcal{S}}$ for the $\infty$-category of large spaces.
As Dylan points out, we have $C^{/f}\cong C\times_{\operatorname{Fun}(C,D)}\operatorname{Fun}(C,D)^{/f}$. So the right fibration $C^{/f}\to C$ classifies the functor $\operatorname{Fun}(C,D)(\delta-,f):D^\mathrm{op}\to\mathcal{S}$, where $\delta:D \to \operatorname{Fun}(C,D)$ is the diagonal embedding. I claim that this functor is the limit of the diagram $$C\xrightarrow{f}D\xrightarrow{j}\mathcal{P}(D)=\operatorname{Fun}(D^\mathrm{op},\mathcal{S}),$$
where $j$ is the Yoneda embedding. Let $F\in\mathcal{P}(D)$ denote the limit of this diagram. It is characterized by the natural equivalence $$\mathcal{P}(D)(-,F)\simeq \operatorname{Fun}(C,\mathcal{P}(D))(\delta -,jf)$$
of functors $\mathcal{P}(D)^\mathrm{op}\to\widehat{\mathcal{S}}$. Restricting this along the Yoneda embedding and using the Yoneda lemma, we obtain a natural equivalence
$$F\simeq\operatorname{Fun}(C,D)(\delta-,f)$$ as required.
