whoizit / vex

Web framework written on V inspired by Express and Sinatra

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vex

Web framework written on V inspired by Express and Sinatra.

Vex is still in its early stages and some of the parts were not implemented yet.

module main

import vex.server as vex
import json
import os

struct Person {
    name string
    doing string
}

fn show_root(req server.Request, res mut server.Response) {
    res.send_file('index.html', 200)  
}

fn print_json(req server.Request, res mut server.Response) {
    res.send_json(json.encode(Person{ name: req.params['name'], doing: req.params['doing'] }), 200)
}

fn log_server(req server.Request, res server.Response) {
    println('${req.path}')
}

fn main() {
    mut s := vex.new()
    s.serve_static('public')
    s.get('/', show_root)
    s.get('/hey/:name/:doing', print_json)
    s.connect(log_server, ['*', '!/hey']) // middleware

    s.serve(6789)
}

vex and vweb

Vex is committed to bring some of its features and optimizations to the vweb framework once it is stable.

Dependencies

Vex uses v-mime to identify MIME types when serving files.

Roadmap

  • Support for GET, POST, PUT, PATCH, DELETE, and OPTION HTTP methods.
  • HTTP Router (wildcards not yet supported)
  • Static file server
  • Params and query parsing
  • Body parsing (supports raw text for now)
  • Middleware support
  • Cookie parsing (basic support)
  • Form data parsing
    • application/x-www-form-urlencoded support
    • multipart/form-data support

Contributing

  1. Fork it (https://github.com/nedpals/vex/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Examples

Examples can be found at the /examples directory.

License

MIT

Contributors

About

Web framework written on V inspired by Express and Sinatra

License:MIT License


Languages

Language:V 100.0%