tags:

views:

66

answers:

1
    public function run() {
 /*
  * wrap uri in a decorator
  */
 $uri = new URI(trim(str_replace($this->base_path, "", $_SERVER["REQUEST_URI"]), "/"));
 /*
  * fetch appropriate resource from uri
  */
 $this->resource = new Resource($uri);
 /*
  * prepare the request
  */
 $request = new Request;
 /*
  * get the response of the app based on the request
  */
 $response = $this->getResponse($request);
 /*
  * send response headers
  */
 $response.sendHeaders();
 /*
  * send response body
  */
 echo $response;
}

This is a "run" function for a web app framework I'm writing. Does my logic of request and response make sense? I'm not actually formally educated with programming. I just read a lot.

A: 

I suppose it makes sense to me -- but it's very vague without knowing your goald and seeing the code for these classes. It looks like the general process of handling a request broken down into the appropriate steps: parse the URI, find some content associated with that URI, send the headers of the content and send the content.

I'm not sure what you're using

$request = new Request;

for. Without seeing the class definition, I don't understand what you're trying to accomplish.

Oh, and

 $response.sendHeaders();

Won't work too well for you :-) You meant

 $response->sendHeaders();
Josh