NIAO
← Blog

Building High-Performance Web Services with Niao and Ahiru

Modern Web Servers in Niao

Web development is first-class in Niao. The ecosystem provides two ways to build servers: a declarative Block DSL for lightweight microservices, and Ahiru, a robust, production-grade web framework.

1. The Block DSL

For simple routes and mock endpoints, Niao provides a built-in block DSL. You can define a server and its routes declaratively inside a single file:

server {
    port = 3000
}

GET "/" {
    return "Hello Niao"
}

GET "/health" {
    return "ok"
}

Run it with a single command:

niao serve web_server.niao

2. The Ahiru Web Framework

When you need middleware, authentication, database integrations, and scalable project structures, Niao provides the Ahiru web framework.

Scaffold a new project in seconds:

niao ahiru create myapi
cd myapi
niao ahiru serve

Here is how you write a simple JSON endpoint in Ahiru:

import "ahiru"

fn main() {
    let app = ahiru_app_new()
    ahiru_app_get(app, "/health", health, {is_public: true})
    ahiru_app_listen(app, "0.0.0.0", 3000)
}

fn health(ctx) {
    return ahiru_json_response(200, "{\"status\":\"ok\"}")
}

Ahiru gives you production-level performance out of the box. As our standard libraries mature, we'll continue adding more database connectors and middleware to Ahiru. Try it out and join the beta to help us shape the future of Niao web services!

Building High-Performance Web Services with Niao and Ahiru | NIAO