Skip to content

Commit

Permalink
Let's make that 1.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
roblillack committed Aug 14, 2018
1 parent 36a7d57 commit 25408dd
Showing 1 changed file with 6 additions and 57 deletions.
63 changes: 6 additions & 57 deletions README.md
Expand Up @@ -8,6 +8,9 @@ A lightweight web toolkit for the [Go language](http://www.golang.org).
[![Coverage Status](https://coveralls.io/repos/github/roblillack/mars/badge.svg?branch=master)](https://coveralls.io/github/roblillack/mars?branch=master)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

- Latest Mars version: 1.0.0
- Support Go versions: 1.8 … 1.11

Mars is a fork of the fantastic, yet not-that-idiomatic-and-pretty-much-abandoned, [Revel framework](https://github.com/revel/revel). You might take a look at the corresponding documentation for the time being.

## Quick Start
Expand Down Expand Up @@ -39,64 +42,10 @@ The major changes since forking away from Revel are these:
- Fix generating reverse routes for some edge cases: Action parameter is called `args` or action parameter is of type `interface{}`.
- Fixed a [XSS vulnerability](https://github.com/roblillack/mars/issues/1).

## Moving from Revel to Mars in 7 steps
1. Add the dependency:
- Add `github.com/roblillack/mars` to your depedencies using the Go vendoring tool of your choice, or
- Add said repository as a git submodule, or
- Just run `go get github.com/roblillack/mars` (which is Go's “I'm feeling lucky” button)
2. Replace all occurences of the `revel` package with `mars`. This will mainly be import paths and
action results (`mars.Result` instead of `revel.Result`), but also things like accessing the config
or logging. You can pretty much automate this.
3. Fix the case for some of the rendering functions your code might call:
- RenderJson -> RenderJSON
- RenderJsonP -> RenderJSONP
- RenderXml -> RenderXML
- RenderHtml -> RenderHTML
4. Set a [Key](https://godoc.org/github.com/roblillack/mars#ValidationResult.Key) for all validation result,
because Mars will _not_ guess this based on variable names. Something like `c.Validation.Required(email)` becomes
`c.Validation.Required(email).Key("email")`
5. Install mars-gen using `go get github.com/roblillack/mars/cmd/mars-gen` and set it up for
controller registration and reverse route generation by adding comments like these to one of Go files:
```
//go:generate mars-gen register-controllers ./controllers
//go:generate mars-gen reverse-routes -n routes -o routes/routes.gen.go ./controllers
```
Make sure to check in the generated sources, too. Run `mars-gen --help` for usage info.
6. Setup a main entry point for your server, for example like this:
```
package main
import (
"flag"
"path"
"github.com/mycompany/myapp/controllers"
"github.com/roblillack/mars"
)
func main() {
mode := flag.String("m", "prod", "Runtime mode to select (default: prod)")
flag.Parse()
// This is the function `mars-gen register-controllers` generates:
controllers.RegisterControllers()
// Setup some paths to be compatible with the Revel way. Default is not to have an "app" directory below BasePath
mars.ViewsPath = path.Join("app", "views")
mars.ConfigFile = path.Join("app", "conf", "app.conf")
mars.RoutesFile = path.Join("app", "conf", "routes")
// Ok, we should never, ever, ever disable CSRF protection.
// But to stay compatible with Revel's defaults ....
// Read https://godoc.org/github.com/roblillack/mars#CSRFFilter about what to do to enable this again.
mars.DisableCSRF = true
// Reads the config, sets up template loader, creates router
mars.InitDefaults(mode, ".")
## Documentation

mars.Run()
}
```
7. Run `go generate && go build && ./myapp` and be happy.
- [Getting started with Mars](http://mars.readthedocs.io/en/latest/getting-started/)
- [Moving from Revel to Mars in 7 steps](http://mars.readthedocs.io/en/latest/migration/)

## Links

Expand Down

0 comments on commit 25408dd

Please sign in to comment.