Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need config file writing approuval #284

Draft
wants to merge 82 commits into
base: master
Choose a base branch
from

Conversation

Acksop
Copy link

@Acksop Acksop commented Mar 1, 2024

Hello,
I've worked on array acceptance on the config file.
Now it seems working with a config file like this :

home : {'GET|POST', '/', 'home#index'};
 : {'GET', '/users/', ['c' => 'UserController', 'a' => 'ListAction']}
users_show : {'GET', '/users/[i:id]', 'users#show'}
users_do : {'POST', '/users/[i:id]/[delete|update:action]', 'usersController#doAction'}

I hope you will enjoy that addition .
Thanks in advance
Emmanuel

@dannyvankooten
Copy link
Owner

Hello,

I don't see this ending up in AltoRouter itself as the majority of users won't be using YAML but I am happy to list this as an available extension in the documentation.

You could leave it separate from the base class entirely and just call $altorouter->addRoutes($arrayFromYaml); after your YAML to array conversion, or you could extend the base AltoRouter class with your modifications. The former method is probably cleaner.

@Acksop Acksop changed the title I've fixed array condition on config file, and tests are passing I've fixed array condition on model config file, inheritance respect of AltoRouter and tests are passing Mar 2, 2024
@Acksop Acksop changed the title I've fixed array condition on model config file, inheritance respect of AltoRouter and tests are passing I've fixed array condition on model config file, inheritance of AltoRouter and tests are passing Mar 2, 2024
@Acksop
Copy link
Author

Acksop commented Mar 12, 2024

Hello, I need your point of view about the implementation of CSV, pure YAML and JSON files
How about this type of config file writing :
CSV config File

'GET|POST', '/', 'home#index','home'
'GET', '/users/', ['c' => 'UserController', 'a' => 'ListAction']
'GET', '/users/[i:id]', 'users#show','users_show'
'POST', '/users/[i:id]/[delete|update:action]', 'usersController#doAction','users_do'

YAML config File

routes:
    - home:
        - 'GET|POST'
        - '/'
        - 'home#index'
    - :
        - 'GET'
        - '/users/'
        - :
            - c : 'UserController'
            - a : 'ListAction'
    - users_show:
        - 'GET'
        - '/users/[i:id]'
        - 'users#show'
    - users_do:
        - 'POST'
        - '/users/[i:id]/[delete|update:action]'
        - 'usersController#doAction'
...

And
JSON config File

{
    "routes": {
        "home": [
            "GET|POST",
            "/",
            "home#index"
        ],
        "": [
            "GET",
            "/users/",
            { "c": "UserController", "a": "ListAction" }
        ],    
        "users_show": [
            "GET",
            "/users/[i:id]",
            "users#show"
        ],
        "users_do": [
            "POST",
            "/users/[i:id]/[delete|update:action]",
            "usersController#doAction"
        ]
    }
}

Can you help me about a good writing of them ?
I hope it will be usefull.

@Acksop Acksop changed the title I've fixed array condition on model config file, inheritance of AltoRouter and tests are passing Need config file writing approuval Mar 16, 2024
Add an extended use of altorouter for efficient use of electricity or speed
fix doc comment
@fixme : name or constant : NEED or USE ?
adding test for use of two new constants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants