#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   {
      uCalc::Transformer router;
      router.Owned(); // Causes router to be released when it goes out of scope
      // --- Define Routes ---
      // General rules first (lower precedence)
      router.FromTo("/products/{category}/{id}", "Handler: ProductDetail, category: {category}, id: {id}");
      router.FromTo("/users/{id}", "Handler: UserProfile, id: {id}");

      // Specific rule last (higher precedence)
      router.FromTo("/users/new", "Handler: CreateUserPage");

      // --- Simulate Requests ---
      vector<string> urls = {"/users/123", "/users/new", "/products/electronics/567", "/contact"};

      for(auto url : urls) {
         auto originalUrl = url;
         auto result = router.Transform(url);

         if (result.Text() == originalUrl) {
            cout << "URL: " << originalUrl << " -> 404 Not Found" << endl;
         } else {
            cout << "URL: " << originalUrl << " -> " << result << endl;
         }
      }
   }
}