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.

Quick Explain

  • ▸Revel provides a full-stack framework with MVC architecture for Go applications.
  • ▸Includes built-in routing, parameter parsing, validation, templating, and session management.
  • ▸Supports hot code reloading to accelerate development iterations.
  • ▸Highly modular and suitable for web APIs, web applications, and services.
  • ▸Focuses on developer productivity and clear structure while leveraging Go’s concurrency and performance.

Core Features

  • ▸Routing and controller dispatch
  • ▸Validation for request parameters
  • ▸Session and cookie management
  • ▸Template rendering with Revel templates
  • ▸Code reloading for development convenience

Learning Path

  • ▸Learn Go programming language
  • ▸Understand MVC architecture
  • ▸Explore Revel routing, controllers, and templates
  • ▸Build small APIs and scale complexity
  • ▸Integrate database and middleware functionality

Practical Examples

  • ▸Build a blog with CRUD operations
  • ▸Develop a REST API for a mobile app
  • ▸Implement authentication and role-based access
  • ▸Create a web dashboard with templating and forms
  • ▸Integrate third-party APIs for payment or notifications

Comparisons

  • ▸Revel vs Gin: Revel full-stack MVC, Gin microframework, faster routing
  • ▸Revel vs Echo: Revel full-featured, Echo minimal and lightweight
  • ▸Revel vs Beego: Both full-featured, Revel simpler configuration
  • ▸Revel vs Node.js/Express: Revel compiled, type-safe; Express dynamic JS
  • ▸Revel vs Django: Revel uses Go; Django uses Python and larger ecosystem

Strengths

  • ▸Quick setup and rapid development
  • ▸Full-featured framework for Go without third-party dependencies
  • ▸Type-safe and performant thanks to Go
  • ▸Good integration with Go’s standard library and concurrency model
  • ▸Clear project structure for scalable apps

Limitations

  • ▸Smaller ecosystem than some other Go frameworks (e.g., Gin, Echo)
  • ▸Less flexible than microframeworks for minimal apps
  • ▸Hot code reload can be limited in production
  • ▸Fewer tutorials and learning resources than larger frameworks
  • ▸Templating engine less advanced than some alternatives

When NOT to Use

  • ▸Teams unfamiliar with Go
  • ▸Very lightweight microservices needing minimal framework
  • ▸Projects requiring large ecosystem of third-party packages
  • ▸Prototyping where Go compilation may slow iteration
  • ▸When hot code reload is critical in production

Cheat Sheet

  • ▸revel new myapp - create new project
  • ▸revel run myapp - run local server
  • ▸revel build myapp - build binary
  • ▸Edit conf/routes - define routes
  • ▸Edit app/controllers/ - create controllers

FAQ

  • ▸Is Revel open-source? -> Yes, MIT license.
  • ▸Can Revel be used in production? -> Yes, Go performance allows production-ready apps.
  • ▸Does Revel support hot code reload? -> Yes, during development.
  • ▸What databases does Revel support? -> Any Go-supported database via sql/db or ORM libraries.
  • ▸Is Revel suitable for REST APIs? -> Yes, commonly used for APIs and web apps.

30-Day Skill Plan

  • ▸Week 1: Install Go, Revel CLI, create simple project
  • ▸Week 2: Build controllers, routes, and views
  • ▸Week 3: Work with models, validation, and sessions
  • ▸Week 4: Add filters and middleware
  • ▸Week 5: Optimize performance and deploy to server

Final Summary

  • ▸Revel is a full-featured Go web framework with MVC architecture.
  • ▸Provides routing, templates, filters, session management, and hot code reload.
  • ▸Suitable for building scalable web applications, APIs, and services in Go.
  • ▸Emphasizes productivity and structured development.
  • ▸Supports deployment as compiled Go binaries for high performance.

Project Structure

  • ▸app/ - controllers, models, views
  • ▸conf/ - configuration files (routes, app.conf)
  • ▸public/ - static assets (CSS, JS, images)
  • ▸tests/ - unit and integration tests
  • ▸logs/ - application logs

Monetization

  • ▸Revel is open-source (MIT license)
  • ▸Commercial support via Go consultants or agencies
  • ▸Enterprise apps benefit from Go performance
  • ▸Training and workshops available
  • ▸Integration with cloud hosting and CI/CD pipelines

Productivity Tips

  • ▸Use Revel CLI for scaffolding
  • ▸Organize controllers and models modularly
  • ▸Use filters and templates effectively
  • ▸Optimize database queries
  • ▸Monitor performance regularly

Basic Concepts

  • ▸Controller - handles HTTP requests and responses
  • ▸Model - encapsulates business logic and data access
  • ▸View - renders HTML using Revel templates
  • ▸Routes - maps URLs to controller actions
  • ▸Filters - middleware-like pre/post request handlers

Official Docs

  • ▸https://revel.github.io
  • ▸Revel GitHub repository
  • ▸Community forums and Slack channels

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher