Skip to content

Commit 4f99a8e

Browse files
committed
Extended F.route(), HTTP method can be a part of URL.
1 parent aed6b8e commit 4f99a8e

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- updated: `GROUP()` by adding a new argument `url_prefix`
2121
- updated: `NEWSCHEMA()` supports `NEWSCHEMA('group/name')`
2222
- updated: `ROUTE()`, extended syntax for schems, for example: `Schema --> @name` (more in docs.)
23+
- updated: `ROUTE()` supports a new HTTP method definition `ROUTE('GET /api/users/')`, `ROUTE('POST /api/users/')`, etc.
2324

2425
- fixed: mail attachments
2526
- fixed: mail `message.manually()`

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,12 @@ F.web = F.route = function(url, funcExecute, flags, length, language) {
16401640
if (!url)
16411641
url = '/';
16421642

1643+
var index = url.indexOf(' ');
1644+
if (index !== -1) {
1645+
flags.push(url.substring(0, index).toLowerCase().trim());
1646+
url = url.substring(index + 1).trim();
1647+
}
1648+
16431649
if (url[0] !== '[' && url[0] !== '/')
16441650
url = '/' + url;
16451651

@@ -1652,7 +1658,6 @@ F.web = F.route = function(url, funcExecute, flags, length, language) {
16521658
url = framework_internal.encodeUnicodeURL(url);
16531659

16541660
var type = typeof(funcExecute);
1655-
var index = 0;
16561661
var urlcache = url;
16571662

16581663
if (!name)

test/controllers/default.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ exports.install = function() {
8787
F.route('/post/json/', plain_post_json, ['json']);
8888
F.route('/post/xml/', plain_post_xml, ['xml']);
8989
F.route('/multiple/', plain_multiple, ['post', 'get', 'put', 'delete']);
90-
F.route('/post/schema/', plain_post_schema_parse, ['post', '*test/User']);
90+
F.route('POST /post/schema/', plain_post_schema_parse, ['*test/User']);
9191
F.route('/rest/', plain_rest, ['post']);
9292
F.route('/rest/', plain_rest, ['put']);
9393
F.route('/rest/', plain_rest, ['get', 'head']);
@@ -113,7 +113,7 @@ exports.install = function() {
113113
assert.ok(F.decrypt('MjM9QR8HExlaHQJQBxcGAEoaFQoGGgAW', 'key', false) === '123456', 'F.decrypt(string)');
114114

115115
assert.ok(F.encrypt({ name: 'Peter' }, 'key', false) === 'MzM9QVUXTkwCThBbF3RXQRlYBkUFVRdOTAJOEFsXdFdBGQ', 'F.encrypt(object)');
116-
assert.ok(F.decrypt('MzM9QVUXTkwCThBbF3RXQRlYBkUFVRdOTAJOEFsXdFdBGQ', 'key').name === 'Peter', 'F.decrypt(object)')
116+
assert.ok(F.decrypt('MzM9QVUXTkwCThBbF3RXQRlYBkUFVRdOTAJOEFsXdFdBGQ', 'key').name === 'Peter', 'F.decrypt(object)');
117117

118118
assert.ok(SOURCE('main').hello() === 'world', 'source');
119119
assert.ok(INCLUDE('main').hello() === 'world', 'source');

0 commit comments

Comments
 (0)