ESP8266WebServer questions; need a hand

I am unable to find much useful-to-me documentation on this library, afaik I'm using the "main" one on github (ESP8266 Community Forum · GitHub) but my question is sorta simple, just requires a bit of background:

I've got my esp setup as an AP-mode webserver that both shows and allows you to manipulate data (simple wifi lightbulb dimmer, more or less, loosely based on the "temperature and humidity sensor" projects all over the web, AP-mode cuz it's more safe (aligned with my personal privacy requirements, quite strict imho but that's OT and prolly preachy)) but I also wanna include a simple 4-digit, 7-segment display and a potentiometer on the unit itself to allow manual usage(screen will show output on a 0-100 scale, dirt simple, and such input/output all works fine). My thought and and the reason for this question was to have a push-button that fires an interrupt, and turns on the wifi but I've got a bunch of code in my setup() (stuff like server.on("/", handleRoot); that I now possibly want/have to run in a separate function. Is this gonna work? something like:

void loop(){

/*lines
of
other
code*/

     if (bIsWIfiOn){
          DoWIfiSetup();
     }else{
     DoWifiShutdown();
     }
}

void DoWifiSetup(){
      if (!bHasSetupWifi){
           dnsServer.start(53, "*", localIp);
           server.begin();
           bHasSetupWifi = true;
      }
}

void DoWifiShutdown(){
      if (bHasSetupWifi){
           dnsServer.stop();
           server.stop();
           bHasSetupWifi = false;
           bIsWifiOn = false;
//or whatever code shuts stuffs off, haven't got that part in front of me anywhere so I just made this up
      }
}

this would be ideal, then I could just leave all the various pages setup in my setup(). If not, how do I handle this?
I know I could just use a "simpler" Arduino Nano or somesuch and avoid the "problem" entirely, but the thing is, I ain't looking for project advice/approach help, just need a little advice on how to program something.

Is this gonna work?

The obvious question is have you tried it ?

stuff like server.on("/", handleRoot); that I now possibly want/have to run in a separate function

What would be the easiest is to just set up the webserver the way you would normally do server.on(), server.begin() etc. (you are planning STA mode as well i see) These things will take up some memory of course but this is not a big issue. And the thing you switch on and off is the WiFi. No Wifi, no client it is simple as that.