request->get('subnet', ''); try { // Validate the input if (!str_contains($subnet, '/')) { throw new Exception('Invalid subnet format.'); } // Delegate calculation to subnet service $subnetInfo = Subnet::calculate($subnet); return $this->response->json() ->with('result', $subnetInfo); } catch (Exception $e) { return $this->response->status(403) ->json() ->with('message', $e->getMessage()); } } }