Configuring the Router

Chilo uses your directory structure as your api routes. This means you don't have to worry about manually setting routes or decorating functions, which might overlap, during your development process. You just need create the handler file in the desired location.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
~~ Directory ~~                         ~~ Route ~~
==========================================================================
πŸ“¦api/                                  |          
β”‚---πŸ“‚handlers                          |           
    β”‚---stores.py                       | /stores    
    β”‚---πŸ“‚item                          |
        β”‚---πŸ“œ__init__.py               | /item
        β”‚---πŸ“œ_item_id.py               | /item/{item_id}
    β”‚---πŸ“‚users                         |
        β”‚---πŸ“œ__init__.py               | /users
        β”‚---πŸ“‚_user_id                  |
            β”‚---πŸ“œ__init__.py           | /users/{user_id}
            β”‚---πŸ“‚pref                  |
                β”‚---πŸ“œ__init__.py       | /users/{user_id}/pref
                β”‚---πŸ“œ_pref_id.py       | /users/{user_id}/pref/{pref_id}