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


Golang goji.Get函数代码示例

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


在下文中一共展示了Get函数的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: Start

func Start(conn *CGRConnector, user, pass string) {
	connector = conn
	username = user
	password = pass
	templates = template.Must(template.ParseGlob("templates/*.tmpl"))

	rpc.Register(conn)

	goji.Get(LOGIN_PATH, loginGet)
	goji.Post(LOGIN_PATH, loginPost)

	goji.Get("/app/*", http.FileServer(http.Dir("./static")))

	auth := web.New()
	goji.Handle("/*", auth)
	auth.Use(SessionAuth)
	auth.Handle("/ws", websocket.Handler(func(ws *websocket.Conn) {
		jsonrpc.ServeConn(ws)
	}))
	auth.Post("/import/", importPost)
	auth.Post("/exportcdrs/", exportCdrsPost)
	auth.Post("/exporttpcsv/", exportTpToCsvPost)
	auth.Get("/accounts/logout", logoutGet)
	auth.Get("/", http.RedirectHandler("/app/", 301))
}
开发者ID:MartinChenjq,项目名称:cgradmin,代码行数:25,代码来源:cgradmin.go

示例3: main

func main() {
	// setup genmai
	db, err := genmai.New(&genmai.SQLite3Dialect{}, ":memory:")
	if err != nil {
		log.Fatalln(err)
	}
	if err := db.CreateTableIfNotExists(&NodeInfo{}); err != nil {
		log.Fatalln(err)
	}

	// setup pongo
	pongo2.DefaultSet.SetBaseDirectory("templates")

	fantasy := &Fantasy{
		DB: db,
	}
	pongo2.Globals["Fantasy"] = fantasy

	// setup goji
	goji.Use(func(c *web.C, h http.Handler) http.Handler {
		fn := func(w http.ResponseWriter, r *http.Request) {
			c.Env["Fantasy"] = fantasy
			h.ServeHTTP(w, r)
		}
		return http.HandlerFunc(fn)
	})

	goji.Get("/", index)
	goji.Post("/create", create)
	goji.Get("/console/:id", console)
	goji.Get("/assets/*", http.FileServer(http.Dir(".")))
	goji.Serve()
}
开发者ID:fgken,项目名称:fantasy,代码行数:33,代码来源:fantasy.go

示例4: main

func main() {
	goji.Get("/", root)
	goji.Get("/slow", slow)
	goji.Get("/bad", bad)
	goji.Get("/timeout", timeout)
	goji.Serve()
}
开发者ID:segfault88,项目名称:rubyvgo1,代码行数:7,代码来源:main.go

示例5: 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

示例6: main

func main() {
	Logger.Formatter = new(logrus.JSONFormatter)

	// init
	db := InitDatabase("./myapp.db")
	defer db.Close()

	// middleware
	goji.Use(func(c *web.C, h http.Handler) http.Handler {
		fn := func(w http.ResponseWriter, r *http.Request) {
			c.Env["DB"] = db
			h.ServeHTTP(w, r)
		}
		return http.HandlerFunc(fn)

	})
	goji.Use(glogrus.NewGlogrus(Logger, "myapp"))
	goji.Use(middleware.Recoverer)
	goji.Use(middleware.NoCache)
	goji.Use(SetProperties)

	// handlers
	goji.Get("/users/", ListUsers)
	goji.Get(regexp.MustCompile(`/users/(?P<name>\w+)$`), GetUser)
	goji.Get("/*", AllMatchHandler)
	goji.Post(regexp.MustCompile(`/users/(?P<name>\w+)$`), RegisterUser)
	goji.Put("/users/:name", UpdateUserInfo)
	goji.Delete("/users/:name", DeleteUserInfo)

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

示例7: main

func main() {

	//setup sessions
	/*
		sh := redis.NewSessionHolder()
		redisconfig := viper.GetStringMapString("redis")
		if _, ok := redisconfig["host"]; !ok {
			panic("failed to read redis host")
		}
		if _, ok := redisconfig["port"]; !ok {
			panic("failed to read redis port")
		}

		redisip, err := alias2ipaddr(redisconfig["host"])
		if err != nil {
			panic("failed to lookup redis IP address")
		}
		goji.Use(redis.BuildRedis(fmt.Sprintf("%s:%s", redisip, redisconfig["port"])))
		goji.Use(base.BuildSessionMiddleware(sh))
	*/

	c := cors.New(cors.Options{
		AllowedOrigins: []string{"*"},
	})
	goji.Use(c.Handler)

	//setup render middleware
	goji.Use(middleware.RenderMiddleware)

	//setup database
	/*
		dbconfig := viper.GetStringMapString("db")
		if _, ok := dbconfig["host"]; !ok {
			panic("failed to read db host")
		}
		if _, ok := dbconfig["name"]; !ok {
			panic("failed to read db name")
		}
		goji.Use(middleware.PostgresMiddleware)

		goji.Use(middleware.AuthMiddleware)
	*/

	//setup routes
	goji.Get("/home", controllers.IndexHandler)
	goji.Get("/healthcheck", controllers.HealthCheckHandler)
	goji.Get("/login", controllers.Login)
	goji.Get("/oauth2callback", controllers.OAuth2Callback)
	//goji.Get("/logout", controllers.Logout)

	//setup static assets
	goji.Use(gojistatic.Static("/go/src/bower_components", gojistatic.StaticOptions{SkipLogging: true, Prefix: "bower_components"}))
	goji.Use(gojistatic.Static("/go/src/frontend/js", gojistatic.StaticOptions{SkipLogging: true, Prefix: "js"}))

	//begin
	log.Info("Starting App...")

	flag.Set("bind", ":80")
	goji.Serve()
}
开发者ID:mikerjacobi,项目名称:goji-skeleton,代码行数:60,代码来源:main.go

示例8: main

func main() {
	kiiApp := models.KiiApp{AppID: "1ef175ad", AppKey: "2a0ed4f8a93d83d9ff3991f75087602d"}

	userCtl := controllers.NewUserController(kiiApp)
	eventCtl := controllers.NewEventController(kiiApp)
	likeCtl := controllers.NewLikeController(kiiApp)

	// Create User
	goji.Post(VERSION+"/user/create", userCtl.CreateUser)
	// Login User
	goji.Post(VERSION+"/user/login", userCtl.LoginUser)
	// Get Login User Info
	goji.Get(VERSION+"/user/me", userCtl.Me)

	// Create Event
	goji.Post(VERSION+"/event", eventCtl.CreateEvent)
	// Delete Event
	goji.Post(VERSION+"/event/delete", eventCtl.DeleteEvent)
	// Get Event
	goji.Get(VERSION+"/events", eventCtl.GetEvents)
	// Add Visit Number
	goji.Post(VERSION+"/event/visit", eventCtl.Visit)

	// Add Like
	goji.Post(VERSION+"/like", likeCtl.AddLike)

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

示例9: main

func main() {
	flag.Parse()

	// Initialize db.
	var db db.DB
	if err := db.Open(*dbFile, 0600); err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	// Initialize wiki.
	w, err := wiki.NewWiki(&db)
	if err != nil {
		log.Fatal(err)
	}

	if *loggerEnabled != true {
		goji.Abandon(middleware.Logger)
	}

	// Setup up the routes for the wiki
	goji.Get("/", w.Show)
	goji.Get("/:name", w.Show)
	goji.Get("/:name/", w.RedirectToShow)
	goji.Get("/:name/edit", w.Edit)
	goji.Post("/:name", w.Update)

	// Start the web server
	goji.Serve()
}
开发者ID:rayleyva,项目名称:wiki,代码行数:30,代码来源:main.go

示例10: 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

示例11: main

func main() {
	createDB()
	goji.Get("/api/posts/", readPosts)
	goji.Post("/api/posts/", insertPost)
	goji.Get("/*", http.FileServer(http.Dir("./static/")))
	goji.Serve()
}
开发者ID:hashrock-sandbox,项目名称:study-golang-bolt-goji,代码行数:7,代码来源:server.go

示例12: StartWebServer

func StartWebServer(bind, auth string) error {
	err := loadTemplates()
	if err != nil {
		return err
	}

	if auth != "" {
		authParts := strings.Split(auth, ":")
		goji.Use(httpauth.SimpleBasicAuth(authParts[0], authParts[1]))
	}

	goji.Get("/", homeRoute)
	goji.Get("/status", statusRoute)
	goji.Get("/robots.txt", robotsRoute)
	goji.Get("/setEnabled", setEnabledRoute)
	goji.Handle("/config", configRoute)

	listener, err := net.Listen("tcp", bind)
	if err != nil {
		return err
	}

	goji.ServeListener(listener)
	return nil
}
开发者ID:topscore,项目名称:sup,代码行数:25,代码来源:webserver.go

示例13: startApi

func startApi(n ApiConfigurationNetwork) {
	apiListener, err := net.Listen("tcp", fmt.Sprintf("%v:%v", n.BindIP, n.BindPort))

	if err != nil {
		panic(err)
	}

	// Adding items:
	goji.Post("/food/add", routeAddFood)

	// Getting items
	goji.Get("/food/get/all", routeGetFoodAll)
	goji.Get("/food/get/id/:id", routeGetFoodById)
	goji.Get("/food/get/date/:year/:month/:day", routeGetFoodByDate)
	// goji.Get("/food/get/name/:name", routeGetFoodByName)

	// Removing items
	goji.Delete("/food/delete/id/:id", routeDeleteFoodById)
	goji.Delete("/food/delete/name/:name", routeDeleteFoodByName)

	// Updating items
	// goji.Put("/food/edit/id/:id", routeUpdateItemById)
	// goji.Put("/food/edit/name/:name", routeUpdateItemByName)

	goji.Get("/food/email/today", routeEmailSendToday)

	goji.ServeListener(apiListener)
}
开发者ID:mrcrilly,项目名称:micro-food-diary,代码行数:28,代码来源:microfood-api.go

示例14: WebServer

func WebServer(ip string, port int) {

	goji.Get("/", func(c web.C, w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "Welcome to the home page!")
	})

	goji.Get("/search", func(c web.C, w http.ResponseWriter, r *http.Request) {
		filter := db.Filter{}
		options := &db.Options{}

		r.ParseForm()
		startDate := r.Form.Get("startDate")
		endDate := r.Form.Get("endDate")

		if startDate != "" {
			filter.StartDate = startDate
		}

		if endDate != "" {
			filter.EndDate = endDate
		}

		order := r.Form["orderby"]
		options.Sort = order

		var results []db.DbObject

		db.Db.Find(&filter, options, &results)
		jsonResults, err := json.Marshal(results)
		if err != nil {
			fmt.Fprint(w, err)
			return
		}

		fmt.Fprintf(w, "%s", string(jsonResults))
	})

	goji.Get("/call/:id", func(c web.C, w http.ResponseWriter, r *http.Request) {
		callId := c.URLParams["id"]
		fmt.Print(callId)
		filter := db.NewFilter()
		options := &db.Options{}

		filter.Equals["callid"] = callId

		var results []db.DbObject
		db.Db.Find(&filter, options, &results)

		jsonResults, err := json.Marshal(results)
		if err != nil {
			fmt.Fprint(w, err)
			return
		}

		fmt.Fprintf(w, "%s", string(jsonResults))

	})

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

示例15: Include

func Include() {
	goji.Get("/", controllers.Home)

	// API
	goji.Get("/api/godocstats", controllers.GodocStats)
	goji.Get("/api/github/stars", controllers.GithubRepoStarsHistory)
}
开发者ID:hypebeast,项目名称:gostats,代码行数:7,代码来源:routes.go


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