Revelのホームページを読んでみる(1
http://revel.github.io/
GolangのWebFramework、Revelのホームページを読んでいきたいと思います。
Go言語による高生産性を誇るWebFramworkだそうです。
現時点でラストリリースが2015/3/25、バージョンが0.12.0です。
Features
Hot Code Reload
Revelは編集されたコード・テンプレートを自動的にコンパイルします。コンパイルが失敗した場合でもわかりやすい説明が表示されます。ランタイムエラーも同様です。
Comprehensive
Revelは以下の機能を提供します。
- routing
- parameter parsing
- validation
- session/flash
- templating
- caching
- job running
- a testing framework
- internationalization
High Performance
RevelはGo Http サーバ上に構築されており、
多様な負荷において、Railsなどと比べて3~10倍速いベンチマークをだしています。
Framework Design
Synchronous
Go Http サーバは各リクエストをGoルーチン上で処理しており、コールバックから解放されたコードを問題なく書けます。
Stateless
Revelは起きるであろうスケーリングに備えて、状態を保持しません。たとえばセッションはユーザのクッキーで賄いますし、キャッシュはredisやメモリに保持します。
Modular
Revelはフィルタと呼ばれるコンポーサブルなミドルウェアを中心に構築されています。それらはリクエストを処理する関数として実装されています。開発者は自由にフィルタを置き換えることができます。
Quick Start
Revelは基本的な使い方を示すためにサンプルアプリケーションを用意しています。
使い方:
1. Revelをインストールします
go get github.com/revel/revel
2. Revelのコマンドラインツールをインストールします
go get github.com/revel/cmd/revel
3. サンプルアプリをインストールします
go get github.com/revel/samples
4. Chatサンプルを起動します
revel run github.com/revel/samples/chat
5. http://localhost:9000/ を開きます
なお私はcloud9上で試しているため、src/revel/samples/chat/conf/app.conf
を次にように編集しました。
http.addr=0.0.0.0
http.port=8080
その際の実行結果を下に載せておきます。
~/workspace (master) $ export GOPATH=~/workspace/golang/
~/workspace (master) $ cd golang/
~/workspace/golang (master) $ go get github.com/revel/revel
~/workspace/golang (master) $ go get github.com/revel/cmd/revel
qooq@demo-project:~/workspace/golang (master) $ export PATH=$PATH:~/workspace/golang/bin
~/workspace/golang (master) $ go get github.com/revel/samples
package github.com/revel/samples
imports github.com/revel/samples
imports github.com/revel/samples: no buildable Go source files in /home/ubuntu/workspace/golang/src/github.com/revel/samples
~/workspace/golang (master) $ revel run github.com/revel/samples/chat
~
~ revel! http://revel.github.io
~
2015/04/21 01:12:57 revel.go:329: Loaded module static
2015/04/21 01:12:57 revel.go:329: Loaded module testrunner
2015/04/21 01:12:57 revel.go:206: Initialized Revel v0.12.0 (2015-03-25) for >= go1.3
2015/04/21 01:12:57 run.go:57: Running chat (github.com/revel/samples/chat) in dev mode
2015/04/21 01:12:57 harness.go:165: Listening on 0.0.0.0:8080
新しいアプリの作成・実行
1. アプリの作成 revel new github.com/my-account/my-app
2. Cloud9の場合、app.confを編集
3. アプリの実行 revel run github.com/my-account/my-app
# The IP address on which to listen.
http.addr = 0.0.0.0
# The port on which to listen.
http.port = 8080
$ revel new github.com/kazusa-qooq/my-app
~
~ revel! http://revel.github.io
~
Your application is ready:
/home/ubuntu/workspace/golang/src/github.com/kazusa-qooq/my-app
You can run it with:
revel run github.com/kazusa-qooq/my-app
$ revel run github.com/kazusa-qooq/my-app
~
~ revel! http://revel.github.io
~
INFO 2015/04/21 01:32:58 revel.go:329: Loaded module testrunner
INFO 2015/04/21 01:32:58 revel.go:329: Loaded module static
INFO 2015/04/21 01:32:58 revel.go:206: Initialized Revel v0.12.0 (2015-03-25) for >= go1.3
INFO 2015/04/21 01:32:58 run.go:57: Running my-app (github.com/kazusa-qooq/my-app) in dev mode
INFO 2015/04/21 01:32:58 harness.go:165: Listening on 0.0.0.0:8080
INFO 2015/04/21 01:32:58 build.go:172: Cleaning dir tmp
ERROR 2015/04/21 01:32:58 build.go:176: Failed to clean dir: open /home/ubuntu/workspace/golang/src/github.com/kazusa-qooq/my-app/app/tmp: no such file or directory
INFO 2015/04/21 01:32:58 build.go:172: Cleaning dir routes
ERROR 2015/04/21 01:32:58 build.go:176: Failed to clean dir: open /home/ubuntu/workspace/golang/src/github.com/kazusa-qooq/my-app/app/routes: no such file or directory
INFO 2015/04/21 01:32:58 build.go:172: Cleaning dir tmp
ERROR 2015/04/21 01:32:58 build.go:176: Failed to clean dir: open /home/ubuntu/workspace/golang/src/github.com/kazusa-qooq/my-app/app/tmp: no such file or directory
INFO 2015/04/21 01:32:58 build.go:172: Cleaning dir routes
ERROR 2015/04/21 01:32:58 build.go:176: Failed to clean dir: open /home/ubuntu/workspace/golang/src/github.com/kazusa-qooq/my-app/app/routes: no such file or directory
INFO 2015/04/21 01:33:01 revel.go:329: Loaded module testrunner
INFO 2015/04/21 01:33:01 revel.go:329: Loaded module static
INFO 2015/04/21 01:33:01 revel.go:206: Initialized Revel v0.12.0 (2015-03-25) for >= go1.3
INFO 2015/04/21 01:33:01 main.go:30: Running revel server
Go to /@tests to run the tests.
Listening on 0.0.0.0:49616...
なんかエラーっぽいのも出てますけど、サーバも起動できましたし、いったん切ります。
次回はRevelのOverviewを読んでいきます。
次回
Author And Source
この問題について(Revelのホームページを読んでみる(1), 我々は、より多くの情報をここで見つけました https://qiita.com/kazusa-qooq/items/ca4435d45f367ee36b72著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .