Skip to content

Instantly share code, notes, and snippets.

@tenntenn
Created March 1, 2013 01:08
Show Gist options
  • Save tenntenn/5061657 to your computer and use it in GitHub Desktop.
Save tenntenn/5061657 to your computer and use it in GitHub Desktop.
Gowebで静的ページとRESTful APIを両方ともハンドリングする ref: http://qiita.com/items/7f532cc883c9ba3151a8
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