当前位置: 首页>>代码示例>>Golang>>正文


Golang goji.Post函数代码示例

本文整理汇总了Golang中github.com/zenazn/goji.Post函数的典型用法代码示例。如果您正苦于以下问题:Golang Post函数的具体用法?Golang Post怎么用?Golang Post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	flag.StringVar(&repoPrefix, "prefix", "", "The repo name prefix required in order to build.")
	flag.Parse()

	if repoPrefix == "" {
		log.Fatal("Specify a prefix to look for in the repo names with -prefix='name'")
	}

	if f, err := os.Stat(sourceBase); f == nil || os.IsNotExist(err) {
		log.Fatalf("The -src folder, %s, doesn't exist.", sourceBase)
	}

	if f, err := os.Stat(destBase); f == nil || os.IsNotExist(err) {
		log.Fatalf("The -dest folder, %s, doesn't exist.", destBase)
	}

	if dbConnString != "" {
		InitDatabase()
	}

	goji.Get("/", buildsIndexHandler)
	goji.Get("/:name/:repo_tag", buildsShowHandler)
	goji.Post("/_github", postReceiveHook)
	goji.Serve()
}
开发者ID:wakermahmud,项目名称:jekyll-build-server,代码行数:25,代码来源:jekyll-build-server.go

示例2: main

func main() {
	// Construct the dsn used for the database
	dsn := os.Getenv("DATABASE_USERNAME") + ":" + os.Getenv("DATABASE_PASSWORD") + "@tcp(" + os.Getenv("DATABASE_HOST") + ":" + os.Getenv("DATABASE_PORT") + ")/" + os.Getenv("DATABASE_NAME")

	// Construct a new AccessorGroup and connects it to the database
	ag := new(accessors.AccessorGroup)
	ag.ConnectToDB("mysql", dsn)

	// Constructs a new ControllerGroup and gives it the AccessorGroup
	cg := new(controllers.ControllerGroup)
	cg.Accessors = ag

	c := cron.New()
	c.AddFunc("0 0 20 * * 1-5", func() { // Run at 2:00pm MST (which is 21:00 UTC) Monday through Friday
		helpers.Webhook(helpers.ReportLeaders(ag))
	})
	c.Start()

	goji.Get("/health", cg.Health)
	goji.Get("/leaderboard", cg.ReportLeaders)
	goji.Post("/slack", cg.Slack) // The main endpoint that Slack hits
	goji.Post("/play", cg.User)
	goji.Post("/portfolio", cg.Portfolio)
	goji.Get("/check/:symbol", cg.Check)
	goji.Post("/buy/:quantity/:symbol", cg.Buy)
	goji.Post("/sell/:quantity/:symbol", cg.Sell)
	goji.Serve()
}
开发者ID:jessemillar,项目名称:stalks,代码行数:28,代码来源:server.go

示例3: Serve

func (a *App) Serve() {
	requestHandlers := &handlers.RequestHandler{
		Config:               &a.config,
		Horizon:              a.horizon,
		TransactionSubmitter: a.transactionSubmitter,
	}

	portString := fmt.Sprintf(":%d", *a.config.Port)
	flag.Set("bind", portString)

	goji.Abandon(middleware.Logger)
	goji.Use(handlers.StripTrailingSlashMiddleware())
	goji.Use(handlers.HeadersMiddleware())
	if a.config.ApiKey != "" {
		goji.Use(handlers.ApiKeyMiddleware(a.config.ApiKey))
	}

	if a.config.Accounts.AuthorizingSeed != nil {
		goji.Post("/authorize", requestHandlers.Authorize)
	} else {
		log.Warning("accounts.authorizing_seed not provided. /authorize endpoint will not be available.")
	}

	if a.config.Accounts.IssuingSeed != nil {
		goji.Post("/send", requestHandlers.Send)
	} else {
		log.Warning("accounts.issuing_seed not provided. /send endpoint will not be available.")
	}

	goji.Post("/payment", requestHandlers.Payment)
	goji.Serve()
}
开发者ID:BIT66COM,项目名称:gateway-server,代码行数:32,代码来源:app.go

示例4: main

func main() {
	//Profiling
	// go func() {
	// 	log.Println(http.ListenAndServe(":6060", nil))
	// }()

	var (
		config *app.Config
	)

	envParser := env_parser.NewEnvParser()
	envParser.Name(appName)
	envParser.Separator("_")
	envSrc := app.Envs{}
	envParseError := envParser.Map(&envSrc)
	app.Chk(envParseError)

	app.PrintWelcome()

	switch envSrc.Mode {
	case app.MODE_DEV:
		logr.Level = logrus.InfoLevel
	case app.MODE_PROD:
		logr.Level = logrus.WarnLevel
	case app.MODE_DEBUG:
		logr.Level = logrus.DebugLevel
	}

	config = app.NewConfig(envSrc.AssetsUrl, envSrc.UploadPath)

	logFile, fileError := os.OpenFile(envSrc.LogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0660)
	defer logFile.Close()
	if fileError == nil {
		logr.Out = logFile
	} else {
		fmt.Println("invalid log file; \n, Error : ", fileError, "\nopting standard output..")
	}

	redisService, reErr := services.NewRedis(envSrc.RedisUrl)
	reErr = reErr

	sqlConnectionStringFormat := "%s:%[email protected](%s:%s)/%s"
	sqlConnectionString := fmt.Sprintf(sqlConnectionStringFormat, envSrc.MysqlUser, envSrc.MysqlPassword,
		envSrc.MysqlHost, envSrc.MysqlPort, envSrc.MysqlDbName)
	mySqlService := services.NewMySQL(sqlConnectionString, 10)

	//TODO check
	baseHandler := handlers.NewBaseHandler(logr, config)
	userHandler := handlers.NewUserHandler(baseHandler, redisService, mySqlService)
	reqHandler := handlers.NewRequestHandler(baseHandler, redisService, mySqlService)

	goji.Post("/register", baseHandler.Route(userHandler.DoRegistration))
	goji.Post("/login", baseHandler.Route(userHandler.DoLogin))
	goji.Get("/bloodReq", baseHandler.Route(reqHandler.RemoveBloodRequest))
	goji.Post("/bloodReq", baseHandler.Route(reqHandler.MakeBloodRequest))
	goji.Delete("/bloodReq", baseHandler.Route(reqHandler.RemoveBloodRequest))
	goji.NotFound(baseHandler.NotFound)

	goji.Serve()
}
开发者ID:PayPal-OpportunityHack-BLR-2015,项目名称:bloodcare-hifx,代码行数:60,代码来源:server.go

示例5: main

func main() {
	// Initalize database.
	ExecuteSchemas()
	// Serve static files.
	staticDirs := []string{"bower_components", "res"}
	for _, d := range staticDirs {
		static := web.New()
		pattern, prefix := fmt.Sprintf("/%s/*", d), fmt.Sprintf("/%s/", d)
		static.Get(pattern, http.StripPrefix(prefix, http.FileServer(http.Dir(d))))
		http.Handle(prefix, static)
	}

	goji.Use(applySessions)
	goji.Use(context.ClearHandler)

	goji.Get("/", handler(serveIndex))
	goji.Get("/login", handler(serveLogin))
	goji.Get("/github_callback", handler(serveGitHubCallback))
	// TODO(samertm): Make this POST /user/email.
	goji.Post("/save_email", handler(serveSaveEmail))

	goji.Post("/group/create", handler(serveGroupCreate))
	goji.Post("/group/:group_id/refresh", handler(serveGroupRefresh))
	goji.Get("/group/:group_id/join", handler(serveGroupJoin))
	goji.Get("/group/:group_id", handler(serveGroup))
	goji.Get("/group/:group_id/user/:user_id/stats.svg", handler(serveUserStatsSVG))

	goji.Serve()
}
开发者ID:samertm,项目名称:githubstreaks,代码行数:29,代码来源:main.go

示例6: initRoutes

func initRoutes() {

	// Setup static files
	static := web.New()
	static.Get("/static/*", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))

	http.Handle("/static/", static)

	// prepare routes, get/post stuff etc
	goji.Get("/", startPage)
	goji.Post("/held/action/:action/*", runActionAndRedirect)
	goji.Post("/held/complexaction", runComplexActionAndRedirect)
	goji.Post("/held/save", saveHeld)

	goji.Get("/held/isValid", isValid)
	// partial html stuff - sub-pages
	goji.Get("/held/page/new", pageNew)
	goji.Get("/held/page/modEigenschaften", pageModEigenschaften)
	goji.Get("/held/page/selectKampftechniken", pageSelectKampftechiken)
	goji.Get("/held/page/allgemeines", pageAllgemeines)
	goji.Get("/held/page/professionsAuswahl", pageAuswahlProfession)
	goji.Get("/held/page/kampftechniken", pageKampftechniken)
	goji.Get("/held/page/talente", pageTalente)
	goji.Get("/held/page/footer", pageFooter)
	goji.Get("/held/page/karmales", pageLiturgien)
	goji.Get("/held/page/magie", pageZauber)

	// json-accessors/ partial rest-API?
	goji.Get("/held/data/ap", getAP)
}
开发者ID:Schokomuesl1,项目名称:bowie,代码行数:30,代码来源:bowieWeb.go

示例7: main

func main() {
	var cfg Config
	stderrBackend := logging.NewLogBackend(os.Stderr, "", 0)
	stderrFormatter := logging.NewBackendFormatter(stderrBackend, stdout_log_format)
	logging.SetBackend(stderrFormatter)
	logging.SetFormatter(stdout_log_format)

	if cfg.ListenAddr == "" {
		cfg.ListenAddr = "127.0.0.1:63636"
	}
	flag.Set("bind", cfg.ListenAddr)
	log.Info("Starting app")
	log.Debug("version: %s", version)

	webApp := webapi.New()
	goji.Get("/dns", webApp.Dns)
	goji.Post("/dns", webApp.Dns)
	goji.Get("/isItWorking", webApp.Healthcheck)

	goji.Post("/redir/batch", webApp.BatchAddRedir)
	goji.Post("/redir/:from/:to", webApp.AddRedir)
	goji.Delete("/redir/:from", webApp.DeleteRedir)
	goji.Get("/redir/list", webApp.ListRedir)

	//_, _ = api.New(api.CallbackList{})

	goji.Serve()
}
开发者ID:efigence,项目名称:go-powerdns,代码行数:28,代码来源:powerdns-remote.go

示例8: initServer

func initServer(conf *configuration.Configuration, conn *zk.Conn, eventBus *event_bus.EventBus) {
	stateAPI := api.StateAPI{Config: conf, Zookeeper: conn}
	serviceAPI := api.ServiceAPI{Config: conf, Zookeeper: conn}
	eventSubAPI := api.EventSubscriptionAPI{Conf: conf, EventBus: eventBus}

	conf.StatsD.Increment(1.0, "restart", 1)
	// Status live information
	goji.Get("/status", api.HandleStatus)

	// State API
	goji.Get("/api/state", stateAPI.Get)

	// Service API
	goji.Get("/api/services", serviceAPI.All)
	goji.Post("/api/services", serviceAPI.Create)
	goji.Put("/api/services/:id", serviceAPI.Put)
	goji.Delete("/api/services/:id", serviceAPI.Delete)

	goji.Post("/api/marathon/event_callback", eventSubAPI.Callback)

	// Static pages
	goji.Get("/*", http.FileServer(http.Dir("./webapp")))

	registerMarathonEvent(conf)

	goji.Serve()
}
开发者ID:rthomas,项目名称:bamboo,代码行数:27,代码来源:bamboo.go

示例9: routing

func routing() {

	///// Website /////

	goji.Get("/", Index)

	/////API///////

	//inscription
	goji.Post("/api/signup", Signup)

	//connexion
	goji.Post("/api/signin", Signin)

	//creation de poste
	goji.Post("/api/post", CreatePost)

	//obtenir ses propres posts
	goji.Get("/api/post", GetOwnPosts)

	//obtenir un post par son id
	goji.Get("/api/post/:id", GetPost)

	//obtenir une liste de post par le login
	goji.Get("/api/:login/post", GetUserPosts)

	//suppresion d'un poste
	goji.Delete("/api/post/:id", DeletePost)

	//comfirmation de l'email si le fichier app.json est configuré pour
	if models.Conf.Status == "prod" || models.Conf.EmailCheck == true {
		goji.Get("/comfirmation", Comfirmation)
	}
}
开发者ID:Fantasim,项目名称:Langage-Go,代码行数:34,代码来源:main.go

示例10: init

func init() {
	goji.Get("/api/sold", store.SoldHandler)
	goji.Post("/api/pay", store.PaymentHandler)
	goji.Get("/api/orders", store.OrdersHandler)
	goji.Post("/api/charge", store.ChargeHandler)
	goji.Post("/api/ship", store.ShipHandler)
	goji.Get("/api/images", images.ImageListHandler)
	goji.Serve()
}
开发者ID:steadicat,项目名称:captured,代码行数:9,代码来源:api.go

示例11: main

func main() {
	host := os.Getenv("ISUCONP_DB_HOST")
	if host == "" {
		host = "localhost"
	}
	port := os.Getenv("ISUCONP_DB_PORT")
	if port == "" {
		port = "3306"
	}
	_, err := strconv.Atoi(port)
	if err != nil {
		log.Fatalf("Failed to read DB port number from an environment variable ISUCONP_DB_PORT.\nError: %s", err.Error())
	}
	user := os.Getenv("ISUCONP_DB_USER")
	if user == "" {
		user = "root"
	}
	password := os.Getenv("ISUCONP_DB_PASSWORD")
	dbname := os.Getenv("ISUCONP_DB_NAME")
	if dbname == "" {
		dbname = "isuconp"
	}

	dsn := fmt.Sprintf(
		"%s:%[email protected](%s:%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
		user,
		password,
		host,
		port,
		dbname,
	)

	db, err = sqlx.Open("mysql", dsn)
	if err != nil {
		log.Fatalf("Failed to connect to DB: %s.", err.Error())
	}
	defer db.Close()

	goji.Get("/initialize", getInitialize)
	goji.Get("/login", getLogin)
	goji.Post("/login", postLogin)
	goji.Get("/register", getRegister)
	goji.Post("/register", postRegister)
	goji.Get("/logout", getLogout)
	goji.Get("/", getIndex)
	goji.Get(regexp.MustCompile(`^/@(?P<accountName>[a-zA-Z]+)$`), getAccountName)
	goji.Get("/posts", getPosts)
	goji.Get("/posts/:id", getPostsID)
	goji.Post("/", postIndex)
	goji.Get("/image/:id.:ext", getImage)
	goji.Post("/comment", postComment)
	goji.Get("/admin/banned", getAdminBanned)
	goji.Post("/admin/banned", postAdminBanned)
	goji.Get("/*", http.FileServer(http.Dir("../public")))
	goji.Serve()
}
开发者ID:catatsuy,项目名称:private-isu,代码行数:56,代码来源:app.go

示例12: main

func main() {
	// HTTP Handlers
	goji.Post("/:topic_name", publishingHandler)
	goji.Post("/:topic_name/:subscriber_name", subscribingHandler)
	goji.Delete("/:topic_name/:subscriber_name", unsubscribingHandler)
	goji.Get("/:topic_name/:subscriber_name", pollingHandler)

	// Serve on the default :8000 port.
	goji.Serve()
}
开发者ID:pmwebster,项目名称:pubsub,代码行数:10,代码来源:main.go

示例13: defineHandlers

func defineHandlers() {
	pref := "/rest/:service/:region"
	goji.Get(pref+"/:resource", indexHandler)
	goji.Get(pref+"/:resource/:id", showHandler)
	goji.Put(pref+"/:resource/:id", updateHandler)
	goji.Post(pref+"/:resource", createHandler)
	goji.Delete(pref+"/:resource/:id", deleteHandler)
	goji.Post(pref+"/action/:action", serviceActionHandler)
	goji.Post(pref+"/:resource/action/:action", collectionActionHandler)
	goji.Post(pref+"/:resource/:id/action/:action", resourceActionHandler)
}
开发者ID:rightscale,项目名称:self-service-plugins,代码行数:11,代码来源:main.go

示例14: main

func main() {
	filename := flag.String("config", "config.toml", "Path to configuration file")

	flag.Parse()
	defer glog.Flush()

	var application = &system.Application{}

	application.Init(filename)
	application.LoadTemplates()

	// Setup static files
	static := web.New()
	publicPath := application.Config.Get("general.public_path").(string)
	static.Get("/assets/*", http.StripPrefix("/assets/", http.FileServer(http.Dir(publicPath))))

	http.Handle("/assets/", static)

	// Apply middleware
	goji.Use(application.ApplyTemplates)
	goji.Use(application.ApplySessions)
	goji.Use(application.ApplyDbMap)
	goji.Use(application.ApplyAuth)
	goji.Use(application.ApplyIsXhr)
	goji.Use(application.ApplyCsrfProtection)
	goji.Use(context.ClearHandler)

	controller := &controllers.MainController{}

	// Couple of files - in the real world you would use nginx to serve them.
	goji.Get("/robots.txt", http.FileServer(http.Dir(publicPath)))
	goji.Get("/favicon.ico", http.FileServer(http.Dir(publicPath+"/images")))

	// Home page
	goji.Get("/", application.Route(controller, "Index"))

	// Sign In routes
	goji.Get("/signin", application.Route(controller, "SignIn"))
	goji.Post("/signin", application.Route(controller, "SignInPost"))

	// Sign Up routes
	goji.Get("/signup", application.Route(controller, "SignUp"))
	goji.Post("/signup", application.Route(controller, "SignUpPost"))

	// KTHXBYE
	goji.Get("/logout", application.Route(controller, "Logout"))

	graceful.PostHook(func() {
		application.Close()
	})
	goji.Serve()
}
开发者ID:matsumana,项目名称:golang-goji-sample,代码行数:52,代码来源:server.go

示例15: main

func main() {
	filename := flag.String("config", "config.json", "Path to configuration file")

	flag.Parse()
	defer glog.Flush()

	var application = &system.Application{}

	application.Init(filename)
	application.LoadTemplates()
	application.ConnectToDatabase()

	// Setup static files
	static := gojiweb.New()
	static.Get("/assets/*", http.StripPrefix("/assets/", http.FileServer(http.Dir(application.Configuration.PublicPath))))

	http.Handle("/assets/", static)

	// Apply middleware
	goji.Use(application.ApplyTemplates)
	goji.Use(application.ApplySessions)
	goji.Use(application.ApplyDatabase)
	goji.Use(application.ApplyAuth)

	controller := &web.Controller{}

	// Couple of files - in the real world you would use nginx to serve them.
	goji.Get("/robots.txt", http.FileServer(http.Dir(application.Configuration.PublicPath)))
	goji.Get("/favicon.ico", http.FileServer(http.Dir(application.Configuration.PublicPath+"/images")))

	// Homec page
	goji.Get("/", application.Route(controller, "Index"))

	// Sign In routes
	goji.Get("/signin", application.Route(controller, "SignIn"))
	goji.Post("/signin", application.Route(controller, "SignInPost"))

	// Sign Up routes
	goji.Get("/signup", application.Route(controller, "SignUp"))
	goji.Post("/signup", application.Route(controller, "SignUpPost"))

	// KTHXBYE
	goji.Get("/logout", application.Route(controller, "Logout"))

	graceful.PostHook(func() {
		application.Close()
	})
	goji.Serve()
}
开发者ID:alexnnovak,项目名称:annsto1,代码行数:49,代码来源:server.go


注:本文中的github.com/zenazn/goji.Post函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。