コード例 #1
0
ファイル: server.go プロジェクト: twainy/tiroler
func route(m *web.Mux) {
	// Add routes to the global handler
	setGetHandler(m, "/", Root)
	// Use Sinatra-style patterns in your URLs
	setGetHandler(m, "/novel/:ncode", responseCache(getNovelInfo))
	setGetHandler(m, "/novel_content/:ncode/:sublist_id", responseCache(getNovelContent))

	// Middleware can be used to inject behavior into your app. The
	// middleware for this application are defined in middleware.go, but you
	// can put them wherever you like.
	m.Use(Json)
}
コード例 #2
0
ファイル: route.go プロジェクト: woremacx/go-crud-sample
func router(m *web.Mux) http.Handler {
	m.Get("/", UserRoot)
	user := web.New()
	goji.Handle("/user/*", user)
	user.Use(middleware.SubRouter)
	user.Get("/", UserIndex)
	user.Get("/new", UserNew)
	user.Post("/new", UserCreate)
	user.Get("/edit/:id", UserEdit)
	user.Post("/update/:id", UserUpdate)
	user.Get("/delete/:id", UserDelete)
	return m
}
コード例 #3
0
ファイル: api.go プロジェクト: mdevilliers/take-home
// Sets up the routes
func (api *Api) Route(m *web.Mux) {

	m.Get("/:topic/:username", api.NextMessage)
	m.Post("/:topic/:username", api.SubscribeToTopic)
	m.Delete("/:topic/:username", api.UnsubscribeFromTopic)

	m.Post("/:topic", api.PublishMessage)

}
コード例 #4
0
ファイル: core.go プロジェクト: grounded042/capacious
// attach r.Handler and r.Method to the correct verb function
func getHandler(wm *web.Mux, r *Route) error {
	switch strings.ToLower(r.Method) {
	case "get":
		wm.Get(r.Pattern, r.Handler)
	case "post":
		wm.Post(r.Pattern, r.Handler)
	case "put":
		wm.Put(r.Pattern, r.Handler)
	case "patch":
		wm.Patch(r.Pattern, r.Handler)
	case "delete":
		wm.Delete(r.Pattern, r.Handler)
	default:
		return errors.New("unsupported method: " + r.Method)
	}

	return nil
}
コード例 #5
0
ファイル: main.go プロジェクト: rightscale/go-boilerplate
// SetupMainServer allocates a listener socket and starts a web server with graceful restart
// on the specified IP address and port. The ipPort has the format "ip_address:port" or
// ":port" for 0.0.0.0/port.
func SetupMainServer(ipPort string, mux *web.Mux) {
	listener, err := net.Listen("tcp4", ipPort)
	if err != nil {
		FatalError(err.Error())
	}

	// Install our handler at the root of the standard net/http default mux.
	// This allows packages like expvar to continue working as expected.
	mux.Compile()
	http.Handle("/", mux)

	graceful.HandleSignals()
	graceful.PreHook(func() { log15.Warn("Gracefully stopping on signal") })
	graceful.PostHook(func() { log.Printf("Gracefully stopped") })

	err = graceful.Serve(listener, http.DefaultServeMux)
	if err != nil {
		FatalError(err.Error())
	}

	graceful.Wait()
}
コード例 #6
0
ファイル: routes.go プロジェクト: tayste5000/go-seed
func Add(mux *web.Mux) {

	/* Endpoint to handler config */
	mux.Get("/", home)
	mux.Get("/home", about)
	mux.Use(mux.Router)

}
コード例 #7
0
ファイル: main.go プロジェクト: masu-mi/face_detector
func route(m *web.Mux) {

	resultMux := web.New()
	resultMux.Get("/face_detect/:name", http.StripPrefix("/face_detect/", http.FileServer(http.Dir("./results/"))))
	resultMux.Use(renameID)

	m.Handle("/face_detect/:name", resultMux)
	m.Get(toolURI, controllers.ControllPannel)
	m.Post(toolURI, controllers.RegisterFace)
}
コード例 #8
0
ファイル: router_mold.go プロジェクト: winespace/goji-mold
func (rm *RouterMold) Generate() *web.Mux {
	var mux *web.Mux
	if rm.SubRoutes == "" {
		mux = goji.DefaultMux
		mux.Abandon(middleware.Logger)
	} else {
		mux := web.New()
		mux.Use(middleware.RequestID)
		mux.Use(middleware.Recoverer)
		mux.Use(middleware.AutomaticOptions)
		goji.Handle(rm.SubRoutes, mux)
	}

	for _, m := range rm.Middlewares {
		mux.Use(m.MiddlewareFunc())
	}

	var handlerFunc func(Route) interface{}
	if rm.HandlerFunc == nil {
		handlerFunc = func(r Route) interface{} {
			return r.Handler
		}
	} else {
		handlerFunc = rm.HandlerFunc
	}

	for _, r := range rm.Routes {
		var pattern interface{}
		if r.RegExp != "" {
			pattern = regexp.MustCompile(r.RegExp)
		} else {
			pattern = r.Path
		}
		switch r.Method {
		case "HEAD":
			mux.Head(pattern, handlerFunc(r))
		case "GET":
			mux.Get(pattern, handlerFunc(r))
		case "POST":
			mux.Post(pattern, handlerFunc(r))
		case "PUT":
			mux.Put(pattern, handlerFunc(r))
		case "PATCH":
			mux.Patch(pattern, handlerFunc(r))
		case "DELETE":
			mux.Delete(pattern, handlerFunc(r))
		}
	}

	return mux
}
コード例 #9
0
ファイル: main.go プロジェクト: born-in-makuhari/kanban
// Route configures routing. it is also used in test-code
func Route(m *web.Mux) {

	m.Get("/hello/:name", hello)
	m.Get("/", root)
}
コード例 #10
0
ファイル: main.go プロジェクト: adulteratedjedi/redishappy
// example handler
func AddHandlers(mux *web.Mux) {
	mux.Get("/api/xxxx", hello)
}
コード例 #11
0
func Route(m *web.Mux) http.Handler {
	m.Get("/user/hello/:name", hello)
	return m
}
コード例 #12
0
ファイル: gaego_sample.go プロジェクト: otiai10/gaego_sample
func route(m *web.Mux) {
	m.Get("/hello/:name", hello)
}
コード例 #13
0
ファイル: routes.go プロジェクト: hypebeast/goji-boilerplate
func Bookmarks(m *web.Mux) {
	goji.Handle("/bookmarks/*", m)
	goji.Get("/bookmarks", http.RedirectHandler("/bookmarks/", 301))

	m.Get("/bookmarks/", controllers.BookmarksHome)
}
コード例 #14
0
ファイル: routes.go プロジェクト: backerman/eveindy
func setRoutes(mux *web.Mux, sde evego.Database, localdb db.LocalDB, xmlAPI evego.XMLAPI,
	eveCentral evego.Market, sessionizer server.Sessionizer, cache evego.Cache) {

	if c.Dev {
		bower := http.FileServer(http.Dir("bower_components"))
		mux.Get("/bower_components/*", http.StripPrefix("/bower_components/", bower))
	}

	mux.Get("/autocomplete/system/:name", api.AutocompleteSystems(sde))
	mux.Get("/autocomplete/station/:name", api.AutocompleteStations(sde, localdb, xmlAPI))
	mux.Post("/pastebin", api.ParseItems(sde))
	marketHandler := api.ItemsMarketValue(sde, eveCentral, xmlAPI)
	// For now these do the same thing. That may change.
	mux.Post("/market/region/:location", marketHandler)
	mux.Post("/market/system/:location", marketHandler)
	mux.Post("/market/station/:id", marketHandler)
	mux.Get("/market/jita", api.ReprocessOutputValues(sde, eveCentral, xmlAPI, cache))

	mux.Post("/reprocess", api.ReprocessItems(sde, eveCentral))
	// SSO!
	auth := evesso.MakeAuthenticator(evesso.Endpoint, c.ClientID, c.ClientSecret,
		c.RedirectURL, evesso.PublicData)
	mux.Get("/crestcallback", api.CRESTCallbackListener(localdb, auth, sessionizer))
	mux.Get("/authenticate", api.AuthenticateHandler(auth, sessionizer))
	mux.Get("/session", api.SessionInfo(auth, sessionizer, localdb))
	mux.Post("/logout", api.LogoutHandler(localdb, auth, sessionizer))

	// API keys
	listHandler, deleteHander, addHandler, refreshHandler := api.XMLAPIKeysHandlers(localdb, sessionizer)
	mux.Get("/apikeys/list", listHandler)
	mux.Post("/apikeys/delete/:keyid", deleteHander)
	mux.Post("/apikeys/add", addHandler)
	mux.Post("/apikeys/refresh", refreshHandler)

	// Standings and skills
	mux.Get("/standings/:charID/:npcCorpID", api.StandingsHandler(localdb, sessionizer))
	mux.Get("/skills/:charID/group/:skillGroupID", api.SkillsHandler(localdb, sessionizer))

	// Blueprints and industry
	_, getBPs := api.BlueprintsHandlers(localdb, sde, sessionizer)
	mux.Get("/blueprints/:charID", getBPs)
	mux.Get("/assets/unusedSalvage/:charID", api.UnusedSalvage(localdb, sde, sessionizer))

	// Static assets
	assets := http.FileServer(http.Dir("dist"))
	mux.Get("/*", assets)
}
コード例 #15
0
ファイル: main.go プロジェクト: kentatogashi/go-memo
func RootRouter(m *web.Mux) {
	m.Get("/", Root)
}
コード例 #16
0
ファイル: main.go プロジェクト: syo-sa1982/SeacherServerSide
func rooter(m *web.Mux) http.Handler {

	m.Get("/admin/", ad.AdminIndex)

	m.Get("/user/index", cntr.UserIndex)
	m.Post("/user/add", cntr.UserAdd)
	m.Post("/user/auth", cntr.UserAuth)

	m.Get("/player/joblist", cntr.JobList)
	m.Post("/player/joblist", cntr.JobList)
	m.Get("/player/base_make", cntr.PlayerBaseMake)
	m.Post("/player/base_make", cntr.PlayerBaseMake)
	m.Post("/player/generate", cntr.PlayerGenerate)
	m.Post("/player/skill_setting", cntr.SkillSetting)
	m.Post("/player/skill_submit", cntr.SkillSubmit)

	m.Post("/home/user/info", cntr.UserInfo)
	m.Get("/home/scenario/list", cntr.ScenarioList)
	m.Post("/home/player/list", cntr.PlayerList)

	return m
}
コード例 #17
0
ファイル: server.go プロジェクト: twainy/tiroler
func setGetHandler(m *web.Mux, pattern interface{}, handler interface{}) {
	m.Get(pattern, handler)
}
コード例 #18
0
	. "github.com/onsi/gomega"
	"github.com/rightscale/go-boilerplate/misc"
	"github.com/rightscale/gojiutil"
	"github.com/zenazn/goji/web"
	"gopkg.in/inconshreveable/log15.v2"
)

// This demo file shows two ways to test the handlers, it is not suggested to use both in a real
// project, the two methods are provided here as a sample.

// Tests that simply create a mux and exercise that by calling the Mux's ServeHTTP function
// This is great for isolated tests, it becomes difficult when the middleware higher in the stack
// is needed or other concurrent goroutines and other handlers al also needed for higher-level tests
var _ = Describe("Mux-based settings tests", func() {

	var mx *web.Mux // mux with the handlers we're testing

	BeforeEach(func() {
		settings = make(map[string]string)
		mx = NewMux()
		gojiutil.AddCommon15(mx, log15.Root())
		mx.Use(gojiutil.ParamsLogger(true)) // useful for troubleshooting
	})

	It("gets what it sets", func() {
		// set a value
		req, _ := http.NewRequest("PUT", "http://example.com/settings/hello?value=world",
			bytes.NewReader([]byte{}))
		resp := httptest.NewRecorder()
		mx.ServeHTTP(resp, req)
		Ω(resp.Code).Should(Equal(200))
コード例 #19
0
ファイル: routes.go プロジェクト: tayste5000/tstevens
func Add(mux *web.Mux) {

	/* Endpoint to handler config */
	mux.Get("/", home)
	mux.Get("/projects", projects)
	mux.Get("/projects/structures", structures)
	mux.Get("/projects/structures/info", structures)
	mux.Handle("/projects/p2drive/*", param2drive.AddRoutes("/projects/p2drive"))
	mux.Get("/contact", contact)
	mux.Get("/site-map", siteMap)
	mux.Get("/faq", faq)

}
コード例 #20
0
ファイル: main.go プロジェクト: woremacx/goji_waf_sample
func rooter(m *web.Mux) http.Handler {
	m.Use(SuperSecure)
	m.Get("/index", UserRoot)
	m.Get("/user/index", UserIndex)
	m.Get("/user/new", UserNew)
	m.Post("/user/new", UserCreate)
	m.Get("/user/edit/:id", UserEdit)
	m.Post("/user/update/:id", UserUpdate)
	m.Get("/user/delete/:id", UserDelete)

	return m
}
コード例 #21
0
ファイル: main.go プロジェクト: kentatogashi/go-memo
func ContentRouter(m *web.Mux) {
	m.Get("/content/", ContentIndex)
	m.Get("/content/index", ContentIndex)
	m.Get("/content/new", ContentNew)
	m.Post("/content/new", ContentCreate)
	m.Get("/content/edit/:id", ContentEdit)
	m.Post("/content/update/:id", ContentUpdate)
	m.Get("/content/delete/:id", ContentDelete)
}