Skip to content

Quick Start

Brian Zou edited this page Jun 3, 2020 · 3 revisions

Create empty project myproject using dub

# dub init myproject

Add Hunt Framework dependency for your project

# cd myproject/
# dub add hunt-framework

Remove source/app.d

# rm -rf source/app.d

Create your project main file source/main.d and install some soruce code

import hunt.framework;

void main(string[] args)
{
    app().run(args);
}

Create controller file source/app/controller/MyController.d

module app.controller.MyController;

import hunt.framework;

class MyController : Controller
{
    mixin MakeController;

    @Action
    string test()
    {
        return "Hello world!";
    }
}

Add config file to config/application.conf

http.address = 127.0.0.1
http.port = 8080

Add route config to config/routes

GET    /    my.test

Add executable to your dub.json

"targetType": "executable"

Build your project

# dub run

View your project using web browser

http://127.0.0.1:8080