Coder Social home page Coder Social logo

revel / revel Goto Github PK

View Code? Open in Web Editor NEW
13.1K 518.0 1.4K 2.76 MB

A high productivity, full-stack web framework for the Go language.

Home Page: http://revel.github.io

License: MIT License

Go 99.08% HTML 0.92%
web-framework web-application web-application-framework hacktoberfest revel

revel's Introduction

Revel Framework

Build Status License Go Report Card

A high productivity, full-stack web framework for the Go language.

Current Version: 1.1.0 (2022-04-11)

Supports go.mod package management

Quick Start

Install Revel:

go install github.com/revel/cmd/revel@latest

Create & Run your app:

revel new -a my-app -r

Open http://localhost:9000 in your browser and you should see "It works!"

Community

Learn More

Contributing

Contributors

revel's People

Contributors

adam-frisby avatar brendensoares avatar casualsuperman avatar davidhunterxyz avatar fzxu avatar huacnlee avatar iamjem avatar jcvernaleo avatar jeevatkm avatar jgraham909 avatar joecohens avatar k0kubun avatar klauspost avatar landaire avatar lokhman avatar longbai avatar mei-rune avatar nolman avatar notzippy avatar ottob avatar pedromorgan avatar ptman avatar pushrax avatar robfig avatar shaban avatar shawncatz avatar tgkokk avatar tmbrggmn avatar torden avatar verdverm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

revel's Issues

x86 linux booking sample / http crash

http://paste.ubuntu.com/1217653/

without repeating too much, I am trying the booking sample and I get this report...

http: panic serving 172.17.98.109:37084: runtime error:
    invalid memory address or nil pointer dereference
/usr/lib/go/src/pkg/net/http/server.go:576

....
/usr/lib/go/src/pkg/github.com/robfig/revel/harness/harness.go:47 (0x46cde3)
    com/robfig/revel/harness.(*Harness).ServeHTTP: renderError(w, r, err)
/usr/lib/go/src/pkg/net/http/server.go:656 (0x4f3ba4)
    (*conn).serve: handler.ServeHTTP(w, w.req)
/build/buildd/golang-1/src/pkg/runtime/proc.c:271 (0x410875)

my version of go is ... too old!
I am an ubuntu user today.

I just tried it in debian sid (x86) and it works flawlessly. Chat example works best in long polling mode, either platform (x86 or arm7)

I guess I can tell you that your target audience is not ubuntu user, if that's something you wanted to put in the documentation? Debian sid recommended

It works with the included golang package for 1.0.2

The Required validator is not satisfied by non-positive integers.

rev.Required's IsSatisfied function returns false if its argument is a non-positive integer.

I feel like this was intentional, but I don't understand when this behavior would be desired. In practice I can see that I'd just use Min and Max for an integer parameter, but to consider an integer parameter "missing" in the sense of Required when it's non-positive isn't intuitive to me.

websocket

Google close code.google.com/p/go.net/websocket link.

Cannot run just-created skeleton

Trying to run a skeleton I created with "rev new rest".

Trying to run "rev run rest" and getting this error:
revel.go:58: Failed to import rest with error: import "rest": cannot find package

I'm assuming it wants my project to be in a specific place... $GOROOT perhaps? How can I let it know where it should be looking... I get an error when I pass an absolute path.

make me confusing code

controller.go line 168
if renderArgNames, ok := methodType.RenderArgNames[line]; ok { why get renderArgNames from methodType.RenderArgNames through index line???? the line was assigned the value through this code "pc, _, line, ok := runtime.Caller(1)"

Documentation error

Hi,

First, congratulations and thanks for this great work!

On the main page of the site, in the quick start it is said:

....
....
go get github.com/robfig/revel/samples/booking/app/controllers
....

Why is this needed? The demo runs well without it as the files on ${GOPATH}/src/github.com/robfig/revel/samples/booking/app/controllers are grabbed by the "go get github.com/robfig/revel"

Pedro Costa

Using gdb with Revel

I started to develop a web app with Go and Revel, and was wondering if there was a way to run my application under gdb. Go itself has support for this but I don't know how to launch Revel with debugging symbols.

Documentation Error: rev.TemplateFuncs

The doc file manual/templates.html states that you can add Template Functions by modifying rev.TemplateFuncs, but the map in Revel is actually called rev.Funcs

Server error function "include" not defined

Hi, I'm try to run the book sample, got same error.

go version go1.0.2

~/gocode/src go build -o ../bin/rev github.com/robfig/revel/cmd
~/gocode/src ../bin/rev run github.com/robfig/revel/samples/booking
~
~ revel! http://robfig.github.com/revel
~
2012/09/10 23:17:01 run.go:38: Running app (dev): booking (/Users/Hong/gocode/src/github.com/robfig/revel/samples/booking)
ERROR 2012/09/10 23:17:01 template.go:192: Template compilation error (In errors/404.html around line 10):
function "include" not defined
INFO 2012/09/10 23:17:01 harness.go:104: Listening on :9000
2012/09/10 23:17:45 main.go:24: Running revel server
ERROR 2012/09/10 23:17:45 template.go:192: Template compilation error (In errors/404.html around line 10):
function "include" not defined
Open DB
Listening on port 49790...
ERROR 2012/09/10 23:17:46 template.go:192: Template compilation error (In errors/404.html around line 10):
function "include" not defined
ERROR 2012/09/10 23:17:46 template.go:192: Template compilation error (In errors/404.html around line 10):
function "include" not defined

chat sample conf/app.conf needs updating?

I just tried sample/chat on FreeBSD 9.1-PRERELEASE (stable) and I don't know if this is the case on other systems, but it looks like something has changed in the config file format, and the config file sample has not moved along with it.

config.go:46: Failed to parse config option log.trace.flags as int: option not found: log.trace.flags
config.go:46: Failed to parse config option log.info.flags as int: option not found: log.info.flags
config.go:46: Failed to parse config option log.warn.flags as int: option not found: log.warn.flags
config.go:46: Failed to parse config option log.error.flags as int: option not found: log.error.flags

This is the latest source pulled from github.com/robfig/revel/samples/chat via go get on a fresh install of go 1.0.2 from source.

Could you update the conf to have sensible defaults? Maybe include a pointer to where the int flags are defined in the sample conf? I set the values to 0 for "do not log" and 2 for "stderr" as a guess, and the warnings disappeared. I have no idea if these are the correct values, and I see that prod section is actually configured to make named log files, so it's probably not that simple.

Documentation error

In the main page, quick start:

bin/rev github.com/robfig/revel/samples/booking

should be:

bin/rev run github.com/robfig/revel/samples/booking

Content-type header being overwritten by revel

Hi Rob!

I'm trying to set a specific content type for response by RenderFile()
c.Response.Out.Header().Set("Content-Type", contype)
The problem is that for *.oex files, the result is being forced to "application/octet-stream" instead of "application/x-opera-extension".
As a workaround, I'm using
c.Response.WriteHeader(http.StatusOK, contype)
but it's quite ugly and produces a warning
"2012/10/18 16:04:52 server.go:281: http: multiple response.WriteHeader calls"

Plugin/module relationship and i18n support

A couple of questions/issues I have come across:

  1. What is the intended relationship between a plugin and a module?

  2. When I want to create a plugin to add functionality (for instance using OnAppStart()), there doesn't seem to be a way for it to register itself.

    Even when embedding it in a module, I couldn't really find a way to let it hook into Revel in order for it to register itself apart from adding a dummy Controller. Am I missing something or is it just not possible at the moment?

Reverse routing

Hey, congrats for Revel, it looks great.

I saw in your wishlist:

  • Reverse routing -- A typesafe reverse router (usable from Controllers and Templates).

Could you explain the typesafe part? And would you consider integrating gorilla/mux (or a lower level one) into Revel?

(I'm the author of gorilla)

Bug in i18n documentation

I've spotted a small bug in the i18n manual documentation:

The application code can access the current locale from within a Controller using the Controller.Locale property.

False! 😅 As the locale isn't stored on the Controller any more. I'll fix it this weekend if no one else has in the meantime.

Package should be named revel or rev, not both

When I create a sample project, it creates the following code in app/controllers/app.go:

package controllers

import "github.com/robfig/revel"

type Application struct {
    *rev.Controller
}

func (c Application) Index() rev.Result {
    return c.Render()
}

But package revel doesn't exist. When "go get" runs, it downloads github.com/robfig/revel with the directory revel, yet you placed all the source code into package "rev". So what I had to do to get gocode to stop complaining was to create a symlink named rev to point to revel and change the import statements to import only rev, not revel.

The gist of this is: Please put the code into package revel if the final directory is named revel, or rename the final directory to rev.

SIGINT handling

When I launch revel using revel run <appname> and then press ctrl+c revel exits cleanly and also terminates the processes launched by the watcher.

If I run it in the background with revel run <appname> & echo $! > web.pid and terminate later with kill -INT $(cat web.pid) the revel process terminates, but leaves the spawned processes alive.

Why is this? Shouldn't it behave exactly the way ctrl-c does?

Extract HTTP related code from mvc.go

As mentioned in issue #39:

Right now mvc.go has the following responsibilities:

  1. The Revel Request/Response types
  2. Extracting more useful information from the http.Request
  3. Registering controllers.
  4. Instantiating controllers.
  5. Providing canned responses when there is no controller. (NotFound, RenderError)

I think extracting 1. and 2. to a new file makes sense. I don't have any great ideas for the name, maybe http.go or request.go?

The http.Request parsing code and Revel request/response wrappers should be extracted to their own source file http.go.

a place in goconfig misleading me

Hi,
Today, I read revel's src, and find a place in goconfig that I can't understand. Can you help me?
in goconfig/config/read.go Line93, why getting the index of "=:" twice, I think inner one is same as the outer one.

// Other alternatives
        default:
            i := strings.IndexAny(l, "=:")

            switch {
            // Option and value
            case i > 0:
                i := strings.IndexAny(l, "=:")
                option = strings.TrimSpace(l[0:i])
                value := strings.TrimSpace(stripComments(l[i+1:]))
                self.AddOption(section, option, value)
            // Continuation of multi-line value
            case section != "" && option != "":
                prev, _ := self.RawString(section, option)
                value := strings.TrimSpace(stripComments(l))
                self.AddOption(section, option, prev+"\n"+value)

            default:
                return errors.New("could not parse line: " + l)
            }
        }

I am use revel on win7 for small test,proxy error found!

when i create a web app named myapp.success,but when i use revel run myapp,
i get an error blow:
reverseproxy.go:111: http: proxy error: dial tcp :50821: The requested address is not valid in its context.
that means the server can not bind on 9000,after that error,the server will print like this:Listening on port 50821...

so i change the port in the browser,ok,it will work,but if i change something in html template,the browser never change until i restart the server

so what is that mean? is there any workaround? thanks!

How to use revel with nosql store?

How to use revel with nosql store?

Wanted to use mgo ...

Does not work, because the interface controller strictly defined type Txn.

How to get around?

Command rev is a generic *NIX tool

This is just a suggestion, but the quick start guide has people output the command line tool as rev, however rev is already a generic *NIX tool. This can cause a bit of confusion of just typing rev instead of ./bin/rev. It may be better to change all the documentation of the command to it's the full name, revel.

As I side note I been playing with revel all week, and its pretty fun framework. Super easy to work with, yet light weight. A real win.

chat sample only works in long polling mode

I tried the chat sample on several platforms and it always works reliably in long polling mode...

WebSockets version usually does not work in Chrome, which was a huge surprise to me. It may have worked once in Firefox. When I want to use the Chat app, I use long polling mode, and maybe that is a good takeaway, but I'm assuming since you offered all of the options, you will want them all to work in the eventual printed copy of the book, even if only on platforms that support that mode of comm socket.

Hot-reload doesn't work on OSX

Just playing around with go and installed revel. Followed the tutorial http://robfig.github.com/revel/tutorial/ (only difference is I used another directory instead of ~/gocode).

Hot-reload doesn't work - neither for go files, nor for templates. The only situation where it does work is if I start the app with a compilation error – I see the error when first loading the app in the browser, then I can fix the error, reload the browser and see the error is gone. Further changes no longer trigger a re-compile though.

go version go1.0.2 (installed using homebrew) on OS X 10.8.2
go env:
GOROOT="/usr/local/Cellar/go/1.0.2"
GOBIN=""
GOARCH="amd64"
GOCHAR="6"
GOOS="darwin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOTOOLDIR="/usr/local/Cellar/go/1.0.2/pkg/tool/darwin_amd64"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread -fno-common"
CGO_ENABLED="1"

revel package: includes zipfile of previous package → ever-growing packages

midna ~/gocode/src/piksku $ rm piksku.zip 
midna ~/gocode/src/piksku $ revel package piksku/                            
midna ~/gocode/src/piksku $ unzip -l piksku.zip | grep piksku.zip
Archive:  piksku.zip
midna ~/gocode/src/piksku $ revel package piksku/                
midna ~/gocode/src/piksku $ unzip -l piksku.zip | grep piksku.zip
Archive:  piksku.zip
  2087615  1980-00-00 00:00   src/piksku/piksku.zip
midna ~/gocode/src/piksku $ echo $GOPATH
/home/michael/gocode

I suppose this should not happen, or if “revel package” should not be called from that directory, there at least should be a warning about it.

To install the sample application on Mac OS X you need pkg-config and sqlite3 dev libraries

[Edit: Title updated, 9/11/12.]

This command from the front page failed on my Mac laptop (10.7.4).

go get github.com/robfig/revel/samples/booking/app/controllers

Error was

pkg-config --cflags sqlite3

exec: "pkg-config": executable file not found in $PATH

Long story short:

Install Homebrew ( http://mxcl.github.com/homebrew/ ):

ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)

Install pkg-config and sqlite3:

brew install pkgconfig
brew install sqlite3

(Note that the pkg-config at mac.softpedia.com (which takes you to SourceForge) is apparently not the right pkg-config.)

And then "go get github.com/robfig/revel/samples/booking/app/controllers" worked.

Thanks for Revel!

Credit to mattn's go-sqlite3 page on github (https://github.com/mattn/go-sqlite3) for the hint on installing Homebrew, pkgconfig, and sqlite3.

Make it possible to watch templates without running the harness

Presently the same configuration variable controls both the use of the harness (for code reloading) as well as for instructing the template loader to watch/reload templates. There is a use case for having the templates watched in production, so this configuration should be split up.

Unable to build master branch since "(WIP) TestRunner supports interactive and commandline testing"

[mjard@GunHead robfig]$ go build -o ~/.local/bin/revel github.com/robfig/revel/cmd
# github.com/robfig/revel/modules/testrunner/app
revel/modules/testrunner/app/plugin.go:5: unknown rev.ErrorResult field 'rev.error' in struct literal


[mjard@GunHead revel]$ git log -n 1
commit 797b0338a86c25afb753538b14946bb9ddeaa394
Author: Rob Figueiredo <[email protected]>
Date:   Fri Nov 9 18:47:57 2012 -0500

    Add a starter test suite to the skeleton app. .gitignore test results

Issues with variadic controller functions

I created a custom controller and added following variadic method to it

func (c *Controller) RenderJsonError(code int, messages ...string) rev.Result

When the route is loaded where this method is used, revel complains with the following message

In web/app/tmp/main.go (around line 33)
28  []*rev.MethodType{
29    &rev.MethodType{
30      Name: "RenderJsonError",
31      Args: []*rev.MethodArg{ 
32          &rev.MethodArg{Name: "code", Type: reflect.TypeOf((*int)(nil)) },
33          &rev.MethodArg{Name: "messages", Type: reflect.TypeOf((*)(nil)) },
34      },
35      RenderArgNames: map[int][]string{ 
36      },
37  },

If I put a []string there instead of ...string no error is reported.

The design of the `set` helper prevents it's use in a pipeline

The set helper presently expects the following argument order: key, value, renderArgs

Because Go template pipelines use the result of the previous expression as the final argument, you can't use them with the set helper. Instead you must use an intermediate variable:

{{$title := printf "Title for %v" .name}}
{{set "title" $title .}}

If renderArgs was moved to the first argument of the set helper, it could be more concise:

{{printf "Title for %v" .name | set . "title"}}

I'm still learning Go, Revel and templates, so my apologies if I am incorrect.

EDIT: It would also make sense to make the same change to append

cannot "revel package"

outroot@cass:~/projects$ revel package testapp
~
~ revel! http://robfig.github.com/revel
~
2012/10/18 19:23:55 run.go:125: Exec: [/home/outroot/dev/go/bin/go build -o /home/outroot/projects/bin/testapp testapp/app/tmp]
Abort: Failed to create directory: mkdir /tmp/testapp794838921/testapp: not a directory

outroot@cass:~/projects$ ls /tmp
testapp794838921
outroot@cass:~/projects$ ls /tmp/testapp794838921/
testapp  github.com
outroot@cass:~/projects$ file /tmp/testapp794838921/testapp
/tmp/testapp794838921/testapp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

So it seems it's trying to create a directory on the ELF executable file.

Documentation: Provide demos of samples

It would be helpful to deploy the sample apps so that developers can try them out while inspecting the code, without forcing them to install / run it.

(Additionally, once we have GAE support, it would be a good demo of that as well)

revel package’s run.sh uses bashisms

run.sh uses pushd and popd which are bashisms, that is, not standardized. However, run.sh declares /bin/sh as interpreter, which is wrong and breaks on systems which have e.g. dash as their /bin/sh.

I suggest changing cmd/package_run.sh.template to this:

#!/bin/sh
SCRIPTPATH=`dirname "$0"`
chmod u+x "$SCRIPTPATH/{{.BinName}}"
"$SCRIPTPATH/{{.BinName}}" -importPath {{.ImportPath}} -srcPath "$SCRIPTPATH/src" -runMode prod

Note the double quotes which are necessary in case the user unpacks the package into a patch which contains spaces.

Password Storage in Example

In the controller example on the front page of the quick start, you show account creation and login. However, the passwords are stored in plain text. While I understand it's not meant to be anything even close to production code, that sort of example being so prominently displayed on the page could well lead developers to follow it and not implement proper security controls.

As such, I'd recommend either showing a different example (without the need for strong security controls) or modifying it to perform proper password storage, namely using an algorithm such as bcrypt or scrypt, or (more practically, in Go), something along the lines of PBKDF2. If the latter option is something you're interested in, I'd be more than willing to help you make this into a solid example of secure password storage, just not sure that's something you want in your first example.

Contribution guidelines and hotspots

Is the list on the wiki page still accurate as to what areas need some work or are good candidates for people to contribute on?

I don't think internationalization has been added yet (I haven't checked everything out yet); but are there any other items? Another handy feature in Play is the job scheduling, for instance.

Thanks!

Embedded builtins will not be exported in later versions of Go

I'm running the tip of Go, and there have popped up some problems with Revel.

After some digging it seems that this issue is the reason: http://code.google.com/p/go/issues/detail?id=4124

The type ErrorResult has the builtin type error embedded. Using Go with the fix to the above issue merged results in the following compilation error:

# github.com/robfig/revel/modules/testrunner/app ..\..\robfig\revel\modules\testrunner\app\plugin.go:5: unknown rev.ErrorResult field 'rev.error' in struct literal

Line 5 of plugin.go is import "github.com/robfig/revel".

The corresponding commit to the Go source is http://code.google.com/p/go/source/detail?r=484bb665fa12

This is not a problem if you are using the latest release of Go, but I just wanted to inform you so it can be handled before it becomes a problem.

Please document how to do incremental deployments

My packaged zipfiles are about 2 MB big. Transferring them to my server takes time, and I’m sure doing an incremental update would be somewhat faster.

I presume that I could just rsync the contents of the zip file, but I’m unsure what revel package does exactly and if it’s reasonable to use revel package, then unpack, then transfer, or whether there is a better way.

Could you please shed some light on this and add it to the documentation? Thanks!

Documentation error Interceptors

func init() {
rev.InterceptFunc(addUser, rev.BEFORE, &Application{})
}

In the interceptor section, I think addUser should be checkLogin

[minor] Blocking vs Synchronous in Homepage

Hi.

I just want to suggest something for the homepage.
The intro describes the framework as Blocking, however, I think a better world would be Synchronous.

Why?
Because is very common to confuse Blocking IO with Synchronous code due the fact all blocking operations are performed by synchronous calls.

My point is, we need to say: Yon't need to use callbacks in go/revel and you still get non-blocking perfomance.

We need those Node.js developers scratching their heads when they read about some other non-blocking platform that is not necessarily asynchronous(callbacks).

Anyway, it's just a suggestion.

This is a great project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.