Beispiel #1
0
void Server::HandleRequestDefault(const Request &request) {
	// First, look through all handlers. If we got one, use it.
	auto handler = handlers_.find(request.resource());
	if (handler != handlers_.end()) {
		(handler->second)(request);
	} else {
		// Let's hit the 404 handler instead.
		fallback_(request);
	}
}
Beispiel #2
0
static const char *current_(const char *profile, const char *key)
{
  static const char general[] = "general";

  /* - - - - - - - - - - - - - - - - - - - *
   * profile lookup order:
   * 1. config: "override"
   * 2. custom: caller provided
   * 3. config: caller provided
   * 4. custom: "general"
   * 5. config: "general"
   * 6. config: "fallback"
   * - - - - - - - - - - - - - - - - - - - */

  const char *res = 0;

  if( (res = override_(key)) )
  {
    // have override value
    goto cleanup;
  }

  if( !xstrnull(res = custom_(profile, key)) )
  {
    // have non-empty custom value for requested profile
    goto cleanup;
  }

  if( (res = config_(profile, key)) )
  {
    // have non-empty default value for requested profile
    goto cleanup;
  }

  if( !xstrsame(profile, general) )
  {
    if( !xstrnull(res = custom_(general, key)) )
    {
      // have non-empty custom value for general profile
      goto cleanup;
    }
    if( (res = config_(general, key)) )
    {
      // have non-empty default value for general profile
      goto cleanup;
    }
  }

  // use the fallback value
  res = fallback_(key);

cleanup:

  return res;
}