A fundamental prediction of the cold dark matter (CDM) model of structure formation is the existence of a vast population of dark matter haloes extending to subsolar masses. By contrast, other possibilities for the nature of the dark matter, such as a warm thermal relic or a sterile neutrino (WDM) predict a cutoff in the mass function at a mass of $sim 10^8~{rm M}_odot$. We use mock observations to demonstrate the viability of a forward modelling approach to extract information on the cosmological number density of low-mass dark matter haloes along the line-of-sight to galaxy-galaxy strong lenses. This can be used to constrain the mass of a thermal relic dark matter particle, $m_mathrm{DM}$. With 50 strong lenses at Hubble Space Telescope resolution and signal-to-noise (similar to the existing SLACS survey), the expected 2$sigma$ constraint for CDM is $m_mathrm{DM} > 3.7 , mathrm{keV}$. If, however, the dark matter is a warm particle of $m_mathrm{DM}=2.2 , mathrm{keV}$, one could rule out $m_mathrm{DM} > 3.2 , mathrm{keV}$. Our [Approximate Bayesian Computation] method can be extended to the large samples of strong lenses that will be observed by future space telescopes, potentially to rule out the standard CDM model of cosmogony. To aid future survey design, we quantify how these constraints will depend on data quality (spatial resolution and integration time) as well as on the lensing geometry (source and lens redshifts).