phpgt / routing Goto Github PK
View Code? Open in Web Editor NEWMiddleware that routes HTTP requests to your code.
Middleware that routes HTTP requests to your code.
If the $dyanmicPath->get()
function is called without a parameter, and there is only one dynamic part to the path, it should return it.
If there is more than one part of the path that's dynamic, and an identifier hasn't been supplied, throw an exception.
Currently, _header and _footer magic files are being loaded before the named view part... but the footer must come afterwards.
The */*
match is inferred for any non-matches. This means that whatever match comes at the end of the class (in order of the functions' declarations) is always preferred for a user agent that requests */*
accept header.
The expected functionality is to match a route only if the */*
is present in the available header matches.
If the matching view/logic files have a dynamic leaf (deepest filename starts with "@"), requests to deeper directories that don't exist still trigger the leaf logic/view.
This might be expected - how else could a deep directory be built? Maybe this needs to be handled separately by a special file - page/@dynamicDir/_deeper.php
for instance?
Logic is now changed...
The purpose of this repository is to provide simple routing capability, specifically for the purpose of extracting the hard-coded rules within WebEngine.
When an HTTP request comes in, the following logic is part of WebEngine:
/page
, /api
or other).HTTP GET /about
=> page/about.html
, something dynamic like HTTP GET /shop/kitchen/fridge
=> page/@category/@item.html
or build up from multiple views including _header.html
, _footer.html
, or anything like that.page/about.html
is backed by page/about.php
), but there are a bunch of extra places logic can be shared.I'm working on a complex project that's causing issues within the Logic Authority.
To recreate, create this page structure:
page
- @outer-id
- - @inner-id
- - - @page-id.html
- - - index.php // redirect to "/outer-123/inner-456/_new"
- - index.php // redirect to "/outer-123/inner-456"
- index.php // redirect to "/outer-123/"
The intention is to redirect the root page through the different layers of automatic ID assignment.
The problem is that the go
function of page/@outer-id/index.php
doesn't fire. It's there in the assembly, but it isn't iterated by the invoke function. Changing it to go_before
does indeed get invoked correctly.
This might not be a bug in the router, but I'm tracking it here.
In a directory with a @dynamic.html, if there is a non-dynamic.php, it can call DynamicPath::get() and it will be returned with its own name, rather than null.
These two tools are currently included in the dev build, but aren't satisfied at the code's quality!
On multiple projects now, an area of the code I'm writing is only interested in the first or last part of the dynamic path. These two functions would be a nice improvement.
Following on from #56, I have found a bug that makes the issue recur when there's a nested dynamic path. Should be an easy fix, as I think this will be resolved by checking the sibling match for each iteration into the uri path parts.
An Assembly represents the source logic/view files that make up the response, but if there are "magic" files in the Assembly (_common, _header, etc.), there's no way of knowing if the Assembly matches any definite file matches.
Dependabot needs to be tamed, as per PhpGt/WebEngine#568
Currently, the page logic is executed before the _common, but for things like authentication, it might make a lot more sense to run _common first.
For consistency, _common.php
should be matched by the MagicFileMatch
class if the current URI matches the containing folder of the _common.php. Currently, _common's go() will only be executed when the URI is deeper.
Pages:
/va/directory/@slug/index.html
/va/directory/@slug/map.html
Viewing /va/directory/somewhere/map/
shows both pages on the same page.
I've hit a bug with the dynamic path object when used without arguemnts. Even though the URL onlymapped to a path with a single @
, the $dynamicPath->get()
returned null
URL: http://localhost:8080/va/venue/vox-conference-centre/
Path: page/va/venue/@slug/index.php
Currently, whether or not there is a distinct file in the assembly is calculated by checking the first character of the filename - if it's an underscore, then it returns false.
Today, I actually wanted to have a file with an underscore, so this broke my functionality.
Really, it should check to see if it's within the MAGIC_FILENAME_ARRAY list.
Get a string representation of the requested URL, with dynamic parts shown.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.