How to find geodesics in metric spaces Let $(X,d)$ be a metric space. Let $x,y\in X$.
How do we generally formulate the problem of finding the shortest path $\gamma :[0,1] \rightarrow X
$ between $x,y$ ? Is it something like 
$$\inf\limits_{\gamma \in C^0} [\sup_{t\in [0,1]}d(x,\gamma(t)) + d(y,\gamma(t))] $$
If so, how do we solve such an optimization problem ? Is there a more convenient way of writing it ?
Example: $X=\mathbb R^2$, $d(x,y)=\|x-y\|$
How do we see that the minimizer of 
$$\inf\limits_{\gamma \in C^0} [\sup_{t\in [0,1]}\|x-\gamma(t)\| + \|y-\gamma(t)\|] $$
is the straight line passing through $x$ and $y$ ? 
Edit: this question is about metric spaces. If possible, the answer should not involve Riemannian geometry in its full generality as I do not know any Riemannian geometry. Also, I know that variational calculus has to do something with this problem (from another  angle). Any insight linking what I wrote to a variational problem is welcome.
 A: It seems likely to me that this question has little in the way of a completely general answer. In the setting of Riemannian geometry, the comment of @Aretino is a good suggestion with some generality. One can also read Riemannian geometry textbooks for proofs of existence theorems for geodesics; those proofs are pretty constructive.
But to address your example question, the most elementary answer in Euclidean geometry is that for each $x \ne y \in \mathbb R^n$ with distance $D = \|x-y\|$, one simply uses coordinate geometry to guess at the formula for the unique geodesic $\gamma : [0,D] \to \mathbb R^n$ such that $\gamma(0)=x$ and $\gamma(1)=D$, namely:
$$\gamma(t) = \left(1-\frac{t}{D}\right) x + \frac{t}{D} y
$$
One must of course check that $\gamma$ is correct, and in fact that it is unique: simply use coordinate geometry to prove that for each $t \in [0,D]$, $\gamma(t)$ is the unique point in $\mathbb R^n$ whose distance to $x$ equals $tD$ and whose distance to $y$ equals $(1-t)D$.
There are several other very homogeneous geometries for which this "guess and check" method also works pretty well, for example the unit $n$ sphere $\mathbb S^n$ embedded in $\mathbb R^n$ and the $n$-dimensional hyperbolic space $\mathbb H^n$ in the hyperboloid model.
