예제 #1
0
파일: network.go 프로젝트: caowenhua/gocar
func Listen() {
	db.SetupDb()
	fmt.Println("begin listen")
	sb := routing.NewSrvSessionBuilder("", "/", "example", 60*60*1000, 10000)
	mux := routing.NewSessionMux("", sb)
	// mux.URL = "127.0.0.1"
	mux.HFunc("/user/reg", Register)
	mux.HFunc("/user/login", Login)
	mux.HFunc("/user/auth", AuthDriver)
	mux.HFunc("/user/fill", FillInfo)
	mux.HFunc("/user/delbyid", DeleteUserById)
	mux.HFunc("/user/delbym", DeleteUserByMobile)

	mux.HFunc("/route/dadd", DriverAddRoute)
	mux.HFunc("/route/padd", PassengerJoinRoute)
	mux.HFunc("/route/pfind", PassengerFindDriver)

	mux.HFunc("/order/charge", ChargeBalance)
	mux.HFunc("/order/withdraw", WithDrawBalance)
	mux.HFunc("/order/dcancel", DriverCancelOrder)
	mux.HFunc("/order/pcancel", PassengerCancelOrder)
	mux.HFunc("/order/dlist", GetDriverOrderList)
	mux.HFunc("/order/plist", GetPassengerOrderList)
	// mux.HFunc("/user/t", TestMethod)
	fmt.Println(http.ListenAndServe(":4455", mux))
}
예제 #2
0
파일: srv.go 프로젝트: Centny/jsupload
func NewSrvMux(pre string, www string) *routing.SessionMux {
	sb := routing.NewSrvSessionBuilder("", "/", "fs", 30*60*1000, 10*1000)
	mux := routing.NewSessionMux(pre, sb)
	// mux.ShowLog = true
	//
	mux.HFunc("^/jsup(\\?.*)?$", jsup.RecF)
	mux.HFunc("^/listBk(\\?.*)?$", jsup.ListBook)
	mux.HFunc("^/listCh(\\?.*)?$", jsup.ListChapter)
	// mux.HFunc("^/store(\\?.*)?$", ctf.StoreCoverage)
	if s_igtest {
		mux.HFunc("/exit", exit)
	}
	mux.Handler("^/.*$", http.FileServer(http.Dir(www)))
	//
	return mux
}
예제 #3
0
파일: mux.go 프로젝트: tomlovzki/ebs
func NewSrvMux(smux *http.ServeMux, pre string, www string) *routing.SessionMux {
	sb := routing.NewSrvSessionBuilder("", "/", "fs", 30*60*1000, 10*1000)
	mux := routing.NewSessionMux(pre, sb)
	// mux.ShowLog = true
	cors := filter.NewCORS()
	cors.AddSite("*")
	mux.HFilter("^/.*$", cors)

	nk := hooks.NewNameHooks()
	//	nk.AddHook(routing.HK_R_END, &trak.HOOK_R_END{})
	//	nk.AddHook(routing.HK_F_BEG, &trak.HOOK_F_BEG{})
	hooks.AddHook(routing.HK_ROUTING, nk)

	//logout
	mux.HFilterFunc("^/logout(\\?.*)?$", uap.ClsUsrStmtFilter)
	mux.HFilterFunc("^/logout(\\?.*)?$", sso.ClsAuthFilter)
	mux.H("^/logout(\\?.*)?$", sso.NewRedirect3(conf.SsoLogoutUrl(), "http://%s"))

	af := sso.NewAuthFilter(
		conf.SsoLoginUrl(),
		conf.SsoAuthUrl(),
		conf.UrlRoot())
	af2 := sso.NewAuthFilter(
		conf.SsoLoginUrl(),
		conf.SsoAuthUrl(),
		conf.UrlRoot())
	afc := sso.NewAuthFilter(
		conf.SsoLoginUrl(),
		conf.SsoAuthUrl(),
		conf.UrlRoot())
	afc.M = "C"
	af2.Optioned = true
	mux.HFilter("^/auth/list-bank-question(\\?.*)?$", af2)
	mux.HFilter("^/usr.*$", afc)
	mux.HFilter("^/usr.*$", af)

	mux.HFilter("^/usr.*$", sync.NewSyncUsrStmtFilter())

	rd := uap.NewRdFilter()
	rd.Default = fmt.Sprintf("%s/%s", pre, "index.html")

	dv := doc.NewDocViewer()
	dv.Excs = []*regexp.Regexp{
		regexp.MustCompile("^\\^/\\.\\*\\$$"),
		regexp.MustCompile("^\\^/api/doc\\.\\*\\$$"),
	}
	mux.H("^/api/doc.*$", dv)

	mux.HFilterFunc("^/usr/ok(\\?.*)?$", sso.Ok)

	mux.HFunc("^/usr/new-question(\\?.*)?$", bank.CreateQuestion)
	mux.HFunc("^/usr/edit-question(\\?.*)?$", bank.EditQuestion)
	mux.HFunc("^/usr/list-bank-question(\\?.*)?$", bank.ListBankQuestion)
	mux.HFunc("^/auth/list-bank-question(\\?.*)?$", bank.ListAuthBankQuestion)
	mux.HFunc("^/usr/del-item(\\?.*)?$", bank.DelItem)
	mux.HFunc("^/usr/del-p2q(\\?.*)?$", bank.DelP2Q)
	mux.HFunc("^/usr/del-qGrp(\\?.*)?$", bank.DelQGrp)

	mux.HFunc("^/usr/new-paper(\\?.*)?$", bank.CreatePaper)
	mux.HFunc("^/usr/edit-paper(\\?.*)?$", bank.EditPaper)
	mux.HFunc("^/usr/get-paper(\\?.*)?$", bank.GetPaperDetail)
	mux.HFunc("^/usr/get-edit-paper(\\?.*)?$", bank.GetEditPaper)

	mux.HFunc("^/usr/new-bank(\\?.*)?$", bank.CreateBank)
	mux.HFunc("^/usr/edit-bank(\\?.*)?$", bank.EditBank)
	mux.HFunc("^/usr/add-p2q(\\?.*)?$", bank.AddP2Q)
	mux.HFunc("^/usr/quote-item(\\?.*)?$", bank.QuoteItem)
	mux.HFunc("^/usr/edit-p2b(\\?.*)?$", bank.EditP2B)

	mux.HFunc("^/usr/list-quote-item(\\?.*)?$", bank.ListQuoteItem)

	mux.HFunc("^/usr/begin-answer(\\?.*)?$", bank.BeginAnswer)
	mux.HFilterFunc("^/usr/submit-answer(\\?.*)?$", bank.SubmitAnswerFilter)
	mux.HFunc("^/usr/submit-answer(\\?.*)?$", bank.SubmitAnswer)
	mux.HFunc("^/usr/save-answer(\\?.*)?$", bank.SaveAnswer)
	mux.HFunc("^/usr/answer-record(\\?.*)?$", bank.GetAnswerRecord)

	mux.HFunc("^/usr/list-pub-bank(\\?.*)?$", bank.ListBank)
	mux.HFunc("^/usr/list-bank-paper(\\?.*)?$", bank.ListBankPaper)
	mux.HFunc("^/auth/list-bank-paper(\\?.*)?$", bank.ListBankPaper)
	mux.HFunc("^/pub/list-bank-paper(\\?.*)?$", bank.ListBankPaper)

	mux.HFunc("^/usr/correct(\\?.*)?$", bank.Correct)
	mux.HFunc("^/usr/correct-remark(\\?.*)?$", bank.CorrectRemark)
	mux.HFunc("^/usr/finish-correct(\\?.*)?$", bank.FinishCorrect)

	mux.HFunc("^/usr/list-bank-record(\\?.*)?$", bank.ListUsrBankRecord)
	mux.HFunc("^/usr/chk-analyze(\\?.*)?$", bank.CheckAnalyze)

	mux.HFunc("^/usr/list-paper-score(\\?.*)?$", bank.ListPaperScore)

	mux.HFunc("^/usr/batch-submit-answer(\\?.*)?$", bank.BatchSubmitAnswer)

	mux.HFunc("^/usr/bank-answer-info(\\?.*)?$", bank.GetBankAnswerCount)
	mux.HFunc("^/usr/bank-answer-group-count(\\?.*)?$", bank.GetBankAnswerGroupCount)
	mux.HFunc("^/usr/batch-correct(\\?.*)?$", bank.BatchCorrect)
	mux.HFunc("^/usr/bank-answer-status(\\?.*)?$", bank.GetBankAnswerStatus)

	mux.HFunc("/api-json(\\?.*)?$", func(hs *routing.HTTPSession) routing.HResult {
		hs.W.Write([]byte(go_swagger.VSwagger.ToString()))
		return routing.HRES_RETURN
	})
	// fid token  pageNUM EXT
	fdl := f_filter.NewFsrvF(conf.INNER_FSRV_URL())
	fdl.RedirectSrv = conf.FSRV_URL()
	mux.H("^/api/usr/dload(\\?.*)?$", fdl)

	mux.Handler("^/.*$", http.FileServer(routing.NewNoCacheDir(www)))
	//

	return mux
}