Support other url configurations #176

Closed
Krinkle opened this Issue May 9, 2012 · 6 comments

Comments

Projects
None yet
2 participants
Member

Krinkle commented May 9, 2012

In order to not depend on a very specific RewriteEngine configuration (in case of Apache), we could also implement settings for path and page-item paths.

And the Linker utility would use those. By default it would be like this:

{
    "page_path": "/index.php?action=$1",
    "page_item_path": "/index.php?action=$1&item=$2",
}

And we could include the following in testswarm-sample.json, matching the recommended .htaccess-sample:

{
    "page_path": "/$1",
    "page_item_path": "/$1/$2",
}
/**
 * @param string $page
 * @param string $item [optional], can be left out if only page or page and query are needed.
 * @param array $query [optional] additional query parameters (appended with [?&]=)
 */
function ( $page, $item = null, $query = array() ) {
}

This would make #174 redundant as feature request (of course we can still add sample configurations for other servers, but it would work out-of-the-box for any web server that supports PHP).

Owner

jzaefferer commented May 9, 2012

I don't yet understand how this would work. Would you still need rewrites?

Member

Krinkle commented May 9, 2012

We would still recommend using rewrites, but TestSwarm would no longer break if you don't want to or can't use rewrites. And urls will automatically use the correct structure based on your configuration.

Owner

jzaefferer commented May 14, 2012

Got it now. Allows you to configure how "pretty" URLs are generated internally. Let's do it!

Member

Krinkle commented Nov 5, 2012

Thinking about this the other day, it does add a layer of complexity. Not just in the backend of TestSwarm, but also for consumers. As given the root of a TestSwarm one can then no longer reliably determine the canonical location of a page.

Though I think that'll be fine as it only applies to the index.php entry, not api.php. Any links an application will generate should/will/do come from the API, which knows the correct location (with the RESTful design, consumers must never form their own urls).

Just thought I'd mention that here.

Owner

jzaefferer commented Nov 5, 2012

consumers must never form their own urls

Would be interesting to see that actually implemented. I don't think I've ever worked with an API where that actually worked out.

I'm still okay with giving it a shot, but we should be careful and question that assumption about never forming your own URLs.

Member

Krinkle commented Aug 8, 2017

TestSwarm currently only encourages Apache and Nginx in their documentation, and we provide easy-to-use sample configuration for those.

While we could make the pretty-url format customizable and disable-able, I don't think there's a strong need for it to be customizable. The main use case would be to allow exposing non-pretty urls (e.g. plain index.php query parameters for everything) on web servers where the installing user prefers not to set up rewrite rules.

I'd prefer not to support that use case given it also makes long-term support difficult given those urls are essentially internal to the application. I'd rather keep a consistent URL interface for the application that can be supported as a public API, and move the requirement of URL rewriting as needed to the web server.

@Krinkle Krinkle closed this Aug 8, 2017

@Krinkle Krinkle added the declined label Aug 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment