Skip to main content
Let’s start with your first Mizu app. You will build a small web server that shows Hello, Mizu in your browser. It is a simple way to see how Mizu works while keeping everything clear and easy to follow. Mizu uses Go’s standard library under the hood, so if you have seen net/http before, this will look familiar.

Code

Create a file called main.go and add this code:
Here is what happens step by step:
  • mizu.New() creates your web app.
  • app.Get("/", home) connects the URL / to your home handler.
  • home() sends a plain text message with status code 200 OK.
  • app.Listen(":8080") runs the server and waits for requests.

Run

Open your terminal and run:
You will see:
Then open http://localhost:8080 in your browser. You should see Hello, Mizu on the screen.

How it works

When you visit /, Mizu matches that route and calls the home function. Inside home, the line c.Text(http.StatusOK, "Hello, Mizu") sends a text response back to the browser with a 200 OK status. This is the basic flow in every Mizu app: receive a request, handle it with a function, and send a response using the context c.

Try something new

You can change the message to anything you like:
Or add another route:
Now if you visit http://localhost:8080/about, you will see your new page. That is it, you have built your first Mizu web server. Next, move on to Static Files to learn how to serve HTML, CSS, and images.