On a proof of Hardy's inequality I'm currently reading a proof of Hardy's inequality for integrals, which states the following: Let $p>1$ , $f \in L^{p}(0,\infty)$ and define $$ g(t) =\frac{1}{t}\int_{0}^{t}f(s)ds, $$ for $t > 0.$ Then one has $\|g\|_{p} \leq \frac{p}{p-1}\|f\|_{p}$. The author I'm reading proves this in the following way. First, he supposes that $f \in C^{\infty}_{c}(0, \infty). $ Then one multiplies both sides of the equation $$f(t) = g(t)+tg'(t)$$ by $p|g|^{p-1}sign(g)$ and integrates both sides. Integrating by parts gives the identity $$p\int_{0}^{\infty} f(t)|g(t)|^{p-1}sign(g)dt = (p-1)\int_{0}^{\infty}|g(t)|^p dt.$$ One concludes by a simple application of Hölder's inequality to get the desired result. Now, I'd like to use the density of $C^{\infty}_{c}(0,\infty)$ functions in $L^p$ to extend the above proof to arbitrary $L^p$ functions. My approach was the following. Take a sequence ${f_n} \in C^{\infty}_{c}$ converging to $f \in L^p$. Without loss of generality $f_n$ converges to $f$ pointwise almost everywhere. The above proof immediately implies $g_n$ is an $L^p$ Cauchy sequence so converges. Showing the limit of the $g_n$ in $L^p$ norm is $g$ would immediately imply the result, but this is where I get stuck. If one can justify using Fatou's lemma, this would also imply the result, but the functions here are not necessarily non-negative. Appreciate if someone could help me out.
 A: Surely there are tidier ways to do this. Are is what I got:
Provided the inequality is obtained for $C_c(0,\infty)$, notice that $Hf=\frac{1}{t}\int^t_0 f$ is linear. for any $f\in L_p$ choose $g_n\in C_c((0,\infty)$ such that $\|f-g_n\|<\frac1n$. Through a subsequence $g_n\rightarrow f$ a.s. Without loss of generality assumptions we can assume that $g_n$ converges to $f$ a.s.
Then Fatou's
$$
\Big|\frac{1}{t}\int^t_0f\Big|^p\leq \Big(\frac{1}{t}\int^t_0|f|\Big)^p\leq \liminf_n\Big(\frac{1}{t}\int^t_0|g_n|\Big)^p$$
Another application of Fatou's gives
$$\begin{align}
\int^\infty_0|Hf|^p&\leq \int^\infty_0\liminf_n\Big(\frac{1}{t}\int^t_0|g_n|\Big)^p\leq \liminf_n\int^\infty_0\big(H|g_n|\big)^p\\
&\leq \Big(\frac{p}{p-1}\Big)^p\liminf_n\|g_n\|^p_p=\Big(\frac{p}{p-1}\Big)^p\|f\|^p_p
\end{align}$$

Comment: Although the technique outlined above works fine for positive integral operators, in general is better to use standard extension techniques from point-set topology:

Suppose $(X,d)$ and $(S,\rho)$ are metric spaces,and  $(S,\rho)$ complete. If $D\subset X$ is dense in $X$ and $f:D\rightarrow S$ satisfies a Lipschitz
$$\begin{align}\rho(f(x),f(y))\leq L d(x,y), \qquad x,y\in D,\tag{1}\label{one}\end{align}$$
then $f$ has a unique extension to $X$, and \eqref{one} holds for all $x,y\in X$

Here is a short proof:
For any $x\in X$, consider a sequence $D\ni x_n\xrightarrow{n\rightarrow\infty}x$ in $X$. Condition \eqref{one} implies that $(f(x_n):n\in\mathbb{N})$ is Cauchy in $S$ and so it converges to some $y^*_x$. If $x'_n$ is another sequence in $D$ that converges to $x$,
$$ \rho(f(x'_n),y^*_x)\leq \rho(f(x'_n),f(x_n))+\rho(f(x_n),y^*)\leq Ld(x'_n,x)+Ld(x,x_n)+\rho(d(x_n),y^*_x)\xrightarrow{n\rightarrow\infty}0$$
Setting $f(x):=y^*_x$ gives extends $f$ uniquely to all of $X$. Now, if $x,y\in X$ and $D\ni x_n\xrightarrow{n\rightarrow\infty}x$ and $D\ni y_n\xrightarrow{n\rightarrow\infty}y$
$$ \begin{align}
\rho(f(x),f(y))&\leq \rho(f(x),f(x_n))+\rho(f(x_n),f(y_n))+\rho(f(y_n),f(y))\\
&\leq \rho(f(x),f(x_n))+ Ld(x_n,x) + Ld(x,y)+L(y,y_n)+\rho(f(y_n),f(y))\\
&\xrightarrow{n\rightarrow\infty}Ld(x,y)\end{align}$$
