Created
May 29, 2013 01:30
-
-
Save JesseObrien/5667377 to your computer and use it in GitHub Desktop.
Revel Hello World app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import "github.com/robfig/revel" | |
type App struct { | |
*revel.Controller | |
} | |
func (c App) Index() revel.Result { | |
greeting := "Hello woooooorld!" | |
return c.Render(greeting) | |
} | |
func (c App) Hello(myName string) revel.Result { | |
c.Validation.Required(myName).Message("Your name is required!") | |
c.Validation.MinSize(myName, 3).Message("Your name is not long enough.") | |
if c.Validation.HasErrors() { | |
c.Validation.Keep() | |
c.FlashParams() | |
return c.Redirect(App.Index) | |
} | |
return c.Render(myName) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{set . "title" "Home"}} | |
{{template "header.html" .}} | |
<h1>Hello {{.myName}}</h1> | |
<a href="/">Back to form</a> | |
{{template "footer.html" .}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{set . "title" "Home"}} | |
{{template "header.html" .}} | |
<h1>{{ .greeting }}</h1> | |
{{range .errors}} | |
<p class="alert">{{.Message}}</p> | |
{{end}} | |
<form action="/App/Hello" method="GET"> | |
<input id="" name="myName" type="text" /> | |
<input type="submit" value="Say Hello!" /> | |
</form> | |
{{template "footer.html" .}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would you mind telling me how to run this app.go?
I tried
both of these failed with following message
Do I have to set this app in $GOPATH?