Created
March 1, 2013 01:08
-
-
Save tenntenn/5061657 to your computer and use it in GitHub Desktop.
Gowebで静的ページとRESTful APIを両方ともハンドリングする ref: http://qiita.com/items/7f532cc883c9ba3151a8
This file contains hidden or 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 main | |
import ( | |
"fmt" | |
"github.com/stretchrcom/goweb/goweb" | |
"net/http" | |
) | |
func main() { | |
// Gowebのコントローラーの登録とかをする | |
// RESTful APIのハンドリング -> Gowebへ | |
http.Handle("/api/", http.StripPrefix("/api", goweb.DefaultHttpHandler)) | |
// 静的ファイルのハンドリング -> ファイルサーバへ | |
http.Handle("/", http.FileServer(http.Dir("static"))) | |
// Webサーバの開始 | |
http.Handle("/", http.FileServer(http.Dir("static"))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment