The party brought before any such officer on the return of any writ of habeas corpus, may deny any of the material facts set forth in the return, or allege any fact to show, either that his imprisonment or detention is unlawful, or that he is entitled to his discharge, which allegations or denials shall be on oath; and thereupon such officer shall proceed in a summary way to hear such allegations and proofs as are legally produced in support of such imprisonment or detention or against the same, and to dispose of such party as justice requires.
NMS § 44-1-25