You can handle a river in a number of ways, and in flat low-lying areas like Northern Italy the management of natural waterways was one of local authorities' major historic concerns. I wrote about that here in the specific context of Milan and Lombardy.
When constructing a fortification, the easiest way to deal with a river is to only fortify one bank. Rivers are already natural barriers. Settlements typically spring up on banks where goods need to be unloaded, or aside bridges and fords. This usually means that the river will be too deep to be crossed at any other point, and even the greenest troops will be averse to crossing a narrow bridge into the jaws of a waiting enemy. This is why the far bank of the river Tiber in Rome (the Trastevere district), the far bank of the Arno in Florence (the Oltrarno) and the far bank of the Adige in Verona (the San Pietro neighborhood) were developed and fortified much later than the city's older core across the water (take a look at this diagram of roman-era Verona as an example; red line representing the city wall only encases the more developed side of the river). All those settlements are also located along bends in their respective rivers, meaning that they are already fairly unassailable from three sides. Even where there is no bridge, the prospect of fording a river or even crossing a shallow waterway will be a strong deterrent for a potential enemy: no one wants to start a battle by traversing open ground while loudly splashing. This is why the city of Venice never had landward-facing walls, even though the Venetian lagoon is only waist-deep in many places. Other cities like Mantua also embraced their aquatic surroundings, with the Mantuans more interested in building fortifications protecting the bridges and causeways connecting the city to its surroundings rather than building high walls where their city was already protected by the wide meanders of the river Mincio.
A second option is to construct fortifications and watchtowers on a strategic point on the opposite bank. Although rivers block military maneuvers, individuals in small boats can still sneak around through a waterway. This could be a major concern: opening the gates to attackers from within is one of easiest and most common ways to win a siege. Fortifying a strategic outpost on the opposite bank can neutralize this threat. In Verona, watch-towers on a hill along the Via Postumia road out of the city date to the roman era, while during the post-roman transformation King Theodoric built fortifications extending from these posts to the bridgeheads on the Adige (you can see that diagrammed here, although beyond defensive concerns encasing bridgeheads in walls is a also a good way to ensure tolls on the bridges are collected). But this does not address what is probably the main point of your question: what happens when a city straddles a river, with two equally important parts that need to be fortified. The only real solution in this case is to fortify the banks of the river leading up to bridges and docks, just as you would fortify the perimeter of the settlement. This is the solution applied by the florentines for the Renaissance-era walls (I found a depiction here, but I knew of a better one that I can't seem to track down right now). The florentines also used wooden contraptions to control the flow of riverboats which could be uses to hamper passage of enemies in times of siege, however there are multiple other ways to protect an enclosed harbor: in Venice and Constantinople, a chain could be raised to bar access to the harbor.
A third option is to change the course of the river itself. This isn't feasible for great rivers like the Tiber or the Arno, although the florentines did unsuccessfully attempt to divert the course of the Arno in the early sixteenth century in order to dry out their rebellious subject Pisa. Cities traversed by smaller rivers did manage to redirect waterways into manageable canals passing through locks that can be sealed shut in times of crisis. This has the added benefit of increasing access to water travel in the city. In the venetian subject of Treviso, the river Botteniga was diverted into canals for the express purpose of making the city walls impenetrable (and indeed they proved to be during the War of the League of Cambrai). The city of Bologna even built artificial canals to increase the amount of waterways in the city, with its original waterway, the torrent Aposa, proving inadequate to fulfill the needs of the increasingly industrious city. Although most of the city's waterways have been interred or diverted underground some tracts are still visible, including the point where the canal carrying water from the river Reno enters the city. The current state of Bologna's waterways leave much to be desired, as the Reno canal immediately dives underground. However you might ascertain from the iron portcullis that the opening was once much higher and carried much more water (as you can see in this much older photograph: the arcaded building on the far end is a church which stands against the opposite side of the tract of city wall in the previous image).
I believe the most extensive example of waterway modification took place in the city of Milan, which I expanded upon in my first link at the top of this answer. Milan located at the point where people and goods from the Po, having moved up the tributaries Nirone or Seveso, can no longer proceed by boat and must be unloaded onto carts in order to be transported through the Telline valleys over the Alps. Because of this, already in the roman era it made little sense for the river to pass through the city. So the shallow river Nirone was diverted away from the city center such that it hugged the western half of the city’s new walls before merging with another river called the Olona. The roman city's eastern limit was instead delineated by the the Seveso, which was also diverted into the Olona in order to form a wide pool at the southern end of the city. This would become one of Northern Italy’s busiest inland ports, and you can get an idea of what the city might have looked like here. As the city grew in the middle ages, a second ring of walls was constructed surrounded by a moat fed by the Seveso and and Olona. You can see what that looked like here, and you'll note that gatehouses match all points save one where water is drawn from the moat to feed the internal canals (which more or less still flank the outline of the roman-era walls). Thus the canals would be watched just as the bridges over the moat were watched.
In Metz, France, the river Seille used to go through the city. At the entry and exit point the medieval fortified wall jumped over the water, thanks to two portes d'eau (water gates). The river is no more, but the remains of the exit porte d'eau is still there.
To better understand what you are looking at, and thanks to the study done by the archeologists and historians of a local association, I've done a 3D restitution of the fortification that you can check here on youtube (with english subtitles).
The interesting things about water gates is that it needed to let the river flow freely, even in flood time ; but it also needed to prevent ennemies or spies to go through it. To achieve this, the Metz city builders choosed a low two-archs bridge (seen here before its destruction), and closed each arch with a kind of heavy portcullis (hence the french name of the bridge, "pont des grilles"). Those grids could be opened up to let through flotsam or ice debris whitch could damage the bridge, and lowered down to prevent any boat or swimmer to go through. The structure went through some destruction in the early 20th c., so the arches remaining today are not the lower ones which are now under the ground ; but rather the inner structure of the rooms where the portcullis mecanism and counterweight seated (as seen on this 19th c. blueprint).
Of course, passive defense was not enough, so the water gate was aso defended by a flanking tower with gunslits to command all the outside section of the gate.
This particular exemple is quite interesting because we have few remaining medieval water gates nowadays, and it gives some idea of the ingenuity needed to defend city rivers. You can find more in the book Défendre Metz à la fin du Moyen-Âge by Julien Trapp and Mylène Didiot (sadly, only in french) or, more conveniently, in this free article (also french, but a lot of pics).