Skip to content

一些建议 #6

@iredmail

Description

@iredmail
  • 老调重弹:去掉 register()。还没人用 V 和 valval,真没必要在这个阶段考虑向后兼容的问题。
  • route 的部分,是否将 http method 从 url 里剥离出来?现在将 http method 直接写进了 url 里,导致在处理的时候还要从字符串里剥离出 http method,多了一个字符串处理的工作。
app.route('POST:/book', function3)  // http://127.0.0.1/book by POST
app.route('DELETE:/book', function4)    // http://127.0.0.1/book by DELETE

也许增加个函数用于接收 http method?例如:

app.routeX('/book', function3, ['POST'])
app.routeX('/book', function4, ['DELETE'])
app.route_get('/book', function3)
app.route_delete('/book', function4)
  • App 能否扩展一下,直接传入一个 map,里面可以有参数:
    • static files 目录
    • debug: bool
    • listen address
    • listen port

例如:

struct Cfg {
        debug bool = false
        static_dirs map[string]string
        listen_address string = '127.0.0.1'
        listen_port int = 8012
}

fn main() {
        cfg := Cfg{debug: false, static_dirs: {'/dir1': '/opt/www/dir1'}, listen_address: '0.0.0.0', listen_port: 8012}
	mut app := valval.new_app(cfg)
	app.route('/', hello)
	valval.runserver()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions