1. Home
  2. /
  3. Revel
  4. /
  5. Simple Todo App

Simple Todo App - Revel Typing CST Test

Loading…

Simple Todo App — Revel Code

Demonstrates a simple Revel controller and view for managing Todo items using MVC architecture.

// app/controllers/todo.go
package controllers

import (
	"github.com/revel/revel"
)

type Todo struct {
	ID        int
	Title     string
	Completed bool
}

var todos []Todo

type TodoController struct {
	*revel.Controller
}

func (c TodoController) Index() revel.Result {
	return c.Render(todos)
}

func (c TodoController) Create(title string) revel.Result {
	todo := Todo{ID: len(todos)+1, Title: title, Completed: false}
	todos = append(todos, todo)
	return c.Redirect(TodoController.Index)
}

// app/views/Todo/Index.html
<h1>Todo List</h1>
<ul>
{{range .todos}}
<li>{{.Title}}</li>
{{end}}
</ul>
<form action="/Todo/Create" method="post">
<input type="text" name="title">
<button type="submit">Add Todo</button>
</form>

Revel Language Guide

Revel is a high-productivity, full-featured web framework for Go (Golang), designed for rapid development of web applications with an MVC architecture, built-in routing, and code reloading.

Primary Use Cases

  • ▸RESTful APIs and microservices
  • ▸Web applications with MVC structure
  • ▸High-performance backend services
  • ▸Prototyping and rapid development
  • ▸Cloud-native Go applications

Notable Features

  • ▸MVC architecture for structured development
  • ▸Hot code reloading for rapid development
  • ▸Built-in routing with parameter handling
  • ▸Validation and session management included
  • ▸Integrated templating system for HTML rendering

Origin & Creator

Created by Rob Figueiredo and maintained by the Revel community since 2011.

Industrial Note

Revel is popular for Go developers who want a structured, Rails-like framework in Go, especially for building APIs and web services with high performance.

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher