本文整理汇总了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()
}
示例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))
}
示例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()
}
示例4: main
func main() {
goji.Get("/", root)
goji.Get("/slow", slow)
goji.Get("/bad", bad)
goji.Get("/timeout", timeout)
goji.Serve()
}
示例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)
}
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例11: main
func main() {
createDB()
goji.Get("/api/posts/", readPosts)
goji.Post("/api/posts/", insertPost)
goji.Get("/*", http.FileServer(http.Dir("./static/")))
goji.Serve()
}
示例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
}
示例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)
}
示例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()
}
示例15: Include
func Include() {
goji.Get("/", controllers.Home)
// API
goji.Get("/api/godocstats", controllers.GodocStats)
goji.Get("/api/github/stars", controllers.GithubRepoStarsHistory)
}