find g(x) given f(x) and the composition (g o f)(x) I've been stuck on this final math problem for ages

I'm given $$f(x) = x^2 + 1$$

and the final composition is $$(g \circ f)(x) = \frac{1}{x^2 + 4}$$

I'm asked to find that $g(x)$ was in order to make this true, but i'm not sure how?
Here's my reasoning:

$$ g(f(x)) = \frac{1}{x^2 + 4} = \frac{1}{(x^2+1)+3}$$

Since $x^2 + 1 = f(x)$

$$g(f(x)) = \frac{1}{f(x)+3} \implies g(x) = \frac{1}{x+3} $$

With $g(x)$, Note: $x \ne -3$ $(x \in \mathbb{R})$
This becomes way easier if you have the knowledge of inverse functions. 

Let me make this clear. You have $f(x) = x^2 + 1$ and  $g(f(x)) = 1/(x^2 + 4)$. Now pause and think about the second function. The function is defined as $g(f(x))$, right. now what if there is some way that you could manipulate this function and some how change it to $g(x)$. Or think about with what other function should you multiply $f(x)$ [the function in $g(f(x))$ ] to get $x$ [so that the function would be $g(x)$]. It is $f(x)^{-1}$ right.

So let us find $f(x)$ inverse.
      $f(x) = x^2 +1$ then $f(x)^{-1} = \sqrt{x - 1}$ right [ just swipe the $x$ with $f(x)$ and solve for $f(x)$ that should give you this result]
now go to the first function $g(f(x))$ [this function is the same as $g(x^2 + 1)$ right.]

Now find $g(\sqrt{x -1})$ (that is $g$ of the inverse function you have found) in the function which is $g( x^2 + 1)$.

Thus the result becomes
$$g((\sqrt{x - 1})^2 + 1) = \frac{1}{(\sqrt{x - 1})^2 + 4}.$$
Now here comes the beauty: what is $(\sqrt{x-1})^2 + 1$? It is $x$, so the value of $g((\sqrt{x-1})^2 + 1) = g(x)$.
Now $$g(x) = \frac{1}{(\sqrt{x - 1})^2 + 4} = \frac{1}{x + 3 }.$$