Пример #1
0
func main() {
	// Host map
	hosts := make(Hosts)

	//-----
	// API
	//-----

	api := echo.New()
	api.Use(mw.Logger())
	api.Use(mw.Recover())

	hosts["api.localhost:1323"] = api

	api.Get("/", func(c *echo.Context) error {
		return c.String(http.StatusOK, "API")
	})

	//------
	// Blog
	//------

	blog := echo.New()
	api.Use(mw.Logger())
	api.Use(mw.Recover())

	hosts["blog.localhost:1323"] = blog

	blog.Get("/", func(c *echo.Context) error {
		return c.String(http.StatusOK, "Blog")
	})

	//---------
	// Website
	//---------

	site := echo.New()
	site.Use(mw.Logger())
	site.Use(mw.Recover())

	hosts["localhost:1323"] = site

	site.Get("/", func(c *echo.Context) error {
		return c.String(http.StatusOK, "Welcome!")
	})

	http.ListenAndServe(":1323", hosts)
}
Пример #2
0
// NewRoutes return routes
func NewRoutes() *echo.Echo {
	bansaku := echo.New()
	bansaku.Static("/js", "static/js")
	bansaku.Static("/css", "static/css/bansaku")
	bansaku.Static("/sound", "static/sound")
	bansaku.Static("/font", "static/font")
	bansaku.Use(mw.Logger())
	bansaku.Use(mw.Recover())
	t := p.PrepareTemplates(p.Options{
		Directory:  "templates/",
		Extensions: []string{".tpl"},
	})
	bansaku.SetRenderer(t)

	// Debug
	bansaku.SetDebug(true)
	server := controllers.NewBansakuServer()
	go server.Start()
	bansaku.Get("/", controllers.BansakuIndex)
	bansaku.WebSocket("/ws", server.BansakuSocketHandler())

	// API
	api := bansaku.Group("/api")
	api.Static("/css", "static/css/api")
	api.Get("/", controllers.APIReferenceHandler)
	api.Get("/count", controllers.APIBansakuGetHandler)

	return bansaku
}
Пример #3
0
func main() {

	loggerService.FileHandle = "server.go"
	loggerService.ErrMsg = string("init server.go")
	loggerService.Count = len("init server.go")
	loggerService.Level = "DEBUG"
	gLoggerService.LogInit(loggerService)
	go putEnginePoll()
	// Echo instance
	e := echo.New()

	// Debug mode
	e.Debug()

	// Middleware
	e.Use(mw.Logger())
	e.Use(mw.Recover())
	e.Use(mw.Gzip())

	// Routes
	e.Get("/expressListUsers", expressListUsers)
	e.Post("/expressEmailMessage", expressEmailMessage)
	e.Post("/expressQueryUsers", expressQueryUsers)
	e.Post("/expressTake", expressTake)
	e.Get("/expressTakeUser", expressTakeUser)

	loggerService.FileHandle = "server.go"
	loggerService.ErrMsg = string("1323 succ server.go")
	loggerService.Count = len("1323 succ server.go")
	loggerService.Level = "DEBUG"
	gLoggerService.LogInit(loggerService)
	// Start server
	e.Run(":1323")
}
Пример #4
0
func main() {

	demoData := Data{
		Id:   5,
		Name: "User name",
		Tags: []string{"people", "customer", "developer"},
	}

	e := echo.New()
	e.SetDebug(true)
	e.Use(middleware.Logger())
	e.Use(middleware.Recover())

	s := stats.New()
	e.Use(standard.WrapMiddleware(s.Handler))

	e.GET("/xml", func(c echo.Context) error {
		return c.XML(200, demoData)
	})

	e.GET("/json", func(c echo.Context) error {
		return c.JSON(200, demoData)
	})

	e.GET("/error", func(c echo.Context) error {
		return echo.NewHTTPError(500, "Error here")
	})

	e.Run(standard.New(":8888"))

}
Пример #5
0
func main() {
	var (
		listen = flag.String("listen", ":3000", "listen address of the application")
		env    = flag.String("env", "dev", "application environment")
	)
	flag.Parse()

	// set the flags into env vars
	os.Setenv("APP_ENV", *env)

	// initialize database connection, with the credentials from the environment.
	repo, err := database.Connect()
	if err != nil {
		panic(err)
	}

	// repo configuration
	repo.LogMode(true)

	// application configuration
	router := echo.New()
	router.SetHTTPErrorHandler(errorHandler)

	router.Use(middleware.Logger(), middleware.Recover())

	registerAuthHandlers(router, handler.AuthService{})

	// V1 API endpoints
	v1 := router.Group("/v1")
	registerUserHandlers(v1, handler.UserService{repo})

	router.Run(*listen)
}
Пример #6
0
func main() {
	// Parse command line arguments
	kingpin.Version("0.0.1")
	kingpin.Parse()

	// Prepare (optionally) embedded resources
	templateBox := rice.MustFindBox("template")
	staticHTTPBox := rice.MustFindBox("static").HTTPBox()
	staticServer := http.StripPrefix("/static/", http.FileServer(staticHTTPBox))

	e := echo.New()

	t := &Template{
		templates: template.Must(template.New("base").Parse(templateBox.MustString("base.html"))),
	}
	e.SetRenderer(t)

	e.Use(middleware.Logger())
	e.Use(middleware.Recover())

	e.GET("/static/*", standard.WrapHandler(staticServer))

	edit := e.Group("/edit")
	edit.Get("/*", EditHandler)
	edit.Post("/*", EditHandlerPost)

	go WaitForServer()
	e.Run(standard.New(fmt.Sprintf("127.0.0.1:%d", *args.Port)))
}
Пример #7
0
func main() {
	conf.Server = env("SERVER", "127.0.0.1")
	conf.Password = env("PASSWORD", "ItsPass1942+")
	conf.User = env("USER", "Administrator")
	conf.SSHPort = env("SSH_PORT", "22")
	conf.instDir = os.Getenv("INSTALLATION_DIR")

	if len(conf.instDir) == 0 {
		conf.instDir = "/var/lib/nanocloud"
	}

	conf.artURL = os.Getenv("ARTIFACT_URL")
	if len(conf.artURL) == 0 {
		conf.artURL = "http://releases.nanocloud.org:8080/releases/latest/"
	}

	// Echo instance
	e := echo.New()

	// Middleware
	e.Use(mw.Logger())
	e.Use(mw.Recover())

	h := handler{
		iaasCon: iaas.New(conf.Server, conf.Password, conf.User, conf.SSHPort, conf.instDir, conf.artURL),
	}

	e.Get("/api/iaas", h.ListRunningVM)
	e.Post("/api/iaas/:id/stop", h.StopVM)
	e.Post("/api/iaas/:id/start", h.StartVM)
	e.Post("/api/iaas/:id/download", h.DownloadVM)

	e.Run(":8080")
}
Пример #8
0
func main() {
	// Check for a linked MongoDB container if we are running in Docker
	mongoHost := os.Getenv("MONGO_PORT_27017_TCP_ADDR")
	if mongoHost == "" {
		mongoHost = "localhost"
	}
	registerURL := flag.String("registerURL", "", "Register a FHIR Subscription to the specified URL")
	registerENV := flag.String("registerENV", "", "Register a FHIR Subscription to the the Docker environment variable IE_PORT_3001_TCP*")
	flag.Parse()
	parsedURL := *registerURL
	if parsedURL != "" {
		registerServer(parsedURL)
	}
	if registerENV != nil {
		registerServer(fmt.Sprintf("http://%s:%s", os.Getenv("IE_PORT_3001_TCP_ADDR"), os.Getenv("IE_PORT_3001_TCP_PORT")))
	}

	e := echo.New()
	session, err := mgo.Dial(mongoHost)
	if err != nil {
		panic("Can't connect to the database")
	}
	defer session.Close()

	basePieURL := discoverSelf() + "pies"
	db := session.DB("riskservice")
	svc := service.NewReferenceRiskService(db)
	svc.RegisterPlugin(assessments.NewCHA2DS2VAScPlugin())
	svc.RegisterPlugin(assessments.NewSimplePlugin())
	fnDelayer := server.NewFunctionDelayer(3 * time.Second)
	server.RegisterRoutes(e, db, basePieURL, svc, fnDelayer)
	e.Use(middleware.Logger())
	e.Run(":9000")
}
Пример #9
0
// GetWebService return a new gin.Engine
func GetWebService(store storage.Storage, auth *Authentication) *echo.Echo {
	log.Printf("[DEBUG] [abraracourcix] Creating web service using %v",
		store)
	ws := v1.NewWebService(store)
	e := echo.New()
	// Middleware
	e.Use(middleware.Logger())
	e.Use(middleware.Recover())
	// Routes
	e.Get("/", ws.Help())
	e.Get("/:url", ws.Redirect())
	e.Get("/api/version", ws.DisplayAPIVersion())
	v1 := e.Group("/api/v1")
	if auth != nil {
		log.Printf("[INFO] [abraracourcix] Setup secure mode : %v", auth)
		v1.Use(middleware.BasicAuth(func(user string, pwd string) bool {
			if user == auth.Username && pwd == auth.Password {
				return true
			}
			return false
		}))
	}
	v1.Get("/urls/:url", ws.URLShow())
	v1.Post("/urls", ws.URLCreate())
	v1.Get("/stats/:url", ws.URLStats())
	return e
}
Пример #10
0
func main() {
	module = nano.RegisterModule("router")

	setupDb()

	conf.UploadDir = env("UPLOAD_DIR", "uploads/")

	handler := httpHandler{
		URLPrefix: "/api",
		Module:    module,
	}

	go module.Listen()

	e := echo.New()
	e.Use(middleware.Logger())
	e.Use(middleware.Recover())
	frontDir := env("FRONT_DIR", "front/")
	e.Static("/", frontDir)
	e.Get("/api/me", getMeHandler)
	e.Get("/api/version", getVersionHandler)
	e.Any("/api/*", handler.ServeHTTP)
	e.Any("/oauth/*", oauthHandler)
	e.Post("/upload", uploadHandler)
	e.Get("/upload", checkUploadHandler)

	addr := ":" + env("PORT", "8080")
	module.Log.Info("Server running at ", addr)
	e.Run(addr)
}
Пример #11
0
func (api *ApiEcho) Handler() http.Handler {
	// Echo instance
	e := echo.New()

	// Middleware
	e.Use(mw.Logger())
	e.Use(mw.Recover())

	// Serve static files
	e.Static("/", "./public")

	// stats https://github.com/thoas/stats
	s := stats.New()
	e.Use(s.Handler)
	e.Get("/stats", func(c *echo.Context) error {
		return c.JSON(http.StatusOK, s.Data())
	})

	// ping
	e.Get("/ping", pingHandler())
	// Set RGB
	e.Get("/rgb/:rgb", rgbHandler(api))
	// SetStabilization
	e.Get("/stable/:bool", stableHandler(api))
	// SetBackLED
	e.Get("/backled/:level", backLedHandler(api))
	// SetHeading
	e.Get("/heading/:heading", headingHandler(api))
	// Roll
	e.Get("/roll/:speed/head/:heading", rollHandler(api))
	// SetRotationRate
	e.Get("/rotate_rate/:level", rotationRateHandler(api))

	return e
}
Пример #12
0
func Init() *echo.Echo {

	e := echo.New()

	e.Debug()

	// Set Bundle MiddleWare
	e.Use(echoMw.Logger())
	e.Use(echoMw.Gzip())
	e.Use(echoMw.CORSWithConfig(echoMw.CORSConfig{
		AllowOrigins: []string{"*"},
		AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAcceptEncoding},
	}))
	e.SetHTTPErrorHandler(handler.JSONHTTPErrorHandler)

	// Set Custom MiddleWare
	e.Use(myMw.TransactionHandler(db.Init()))

	// Routes
	v1 := e.Group("/api/v1")
	{
		v1.POST("/members", api.PostMember())
		v1.GET("/members", api.GetMembers())
		v1.GET("/members/:id", api.GetMember())
	}
	return e
}
Пример #13
0
func main() {
	cmd := kingpin.MustParse(app.Parse(os.Args[1:]))

	aws_config := aws.NewConfig()

	skipp3r = Skipp3r{
		Bucket:  bucket,
		Prefix:  prefix,
		Version: version,
		Svc:     s3.New(aws_config),
	}

	switch cmd {
	case get.FullCommand():
		res := skipp3r.get(getPath)
		fmt.Println(res)
	case set.FullCommand():
		err := skipp3r.set(srcPath, destPath, doDelete)
		fmt.Println(err)
	case daemon.FullCommand():
		e := echo.New()

		e.Use(mw.Logger())
		e.Use(mw.Recover())

		e.Get("/", getHandler)
		e.Get("/:path", getHandler)
		e.Run(":" + *port)
	}
}
Пример #14
0
func main() {
	// Echo instance
	e := echo.New()

	// Debug mode
	e.Debug()

	//------------
	// Middleware
	//------------

	// Logger
	e.Use(mw.Logger())

	// Recover
	e.Use(mw.Recover())

	// Basic auth
	e.Use(mw.BasicAuth(func(usr, pwd string) bool {
		if usr == "joe" && pwd == "secret" {
			return true
		}
		return false
	}))

	// Gzip
	e.Use(mw.Gzip())

	// Routes
	e.Get("/", hello)

	// Start server
	e.Run(":1323")
}
Пример #15
0
func main() {
	//runtime.GOMAXPROCS(runtime.NumCPU())
	e := echo.New()

	e.Use(mw.Logger())
	e.Use(mw.Recover())
	e.Use(mw.Gzip())

	e.Get("/", welcome)
	e.Get("/ping", ping)

	//// Start server
	//e.Run(":1323")

	// Get the http.Server
	s := e.Server(":8000")

	// HTTP2 is currently enabled by default in echo.New(). To override TLS handshake errors
	// you will need to override the TLSConfig for the server so it does not attempt to validate
	// the connection using TLS as required by HTTP2
	s.TLSConfig = nil

	// Serve it like a boss
	log.Fatal(gracehttp.Serve(s))
}
Пример #16
0
func (as ApiService) registerMiddlewares() {
	// Middlewares
	as.echo.HTTPErrorHandler = CustomHTTPErrorHandler

	as.echo.Use(middleware.Logger())
	as.echo.Use(middleware.Recover())
}
Пример #17
0
func main() {
	port := "8080"

	e := echo.New()
	e.SetDebug(true)

	e.Use(mw.Logger())
	e.Use(mw.Recover())
	e.StripTrailingSlash()

	assetHandler := http.FileServer(assetFS())

	e.Get("/clicks", buttonsStateHandler)
	e.Post("/click/:button", buttonClicker)
	e.WebSocket("/ws", socketHandler)
	e.Get("/*", func(c *echo.Context) error {
		assetHandler.ServeHTTP(c.Response().Writer(), c.Request())
		return nil
	})

	// Start the "message hub"
	go hub.Run()

	// Detect clicks on buttons
	btns = newButtons()
	defer btns.Close()
	btns.Run()

	// Control the leds based on clicks
	newLeds(btns, hub)

	// Start server
	log.Println("Starting server on port " + port)
	graceful.ListenAndServe(e.Server(":"+port), 2*time.Second)
}
Пример #18
0
func main() {
	e := echo.New()

	e.Use(mw.Logger())
	e.Use(mw.Recover())

	e.Static("/", "public")
	e.WebSocket("/ws", func(c *echo.Context) (err error) {
		ws := c.Socket()
		msg := ""

		for {
			if err = websocket.Message.Send(ws, "Hello, Client!"); err != nil {
				return
			}
			if err = websocket.Message.Receive(ws, &msg); err != nil {
				return
			}
			println(msg)
		}
		return
	})

	e.Run(":1323")
}
Пример #19
0
//Start метод запускает веб-интерфейс
func (mw *ManagerWeb) Start() error {
	go func() {
		if mw.e == nil {
			mw.e = echo.New()
		}

		mw.e.Use(mid.Logger()) // выводить лог
		//mw.e.Use(mid.Recover())	// игнорировать ошибки при работе сервера

		mw.e.Get("/", hello) // будущая основная страница

		//api
		mw.e.Get("/api/bots", listBot)                      // вывести json-список текущих ботов
		mw.e.Post("/api/bots", createBot)                   // создать нового бота
		mw.e.Patch("/api/bot/:id/:action", sendActionToBot) // отправить основные команды боту (старт, стоп...)
		mw.e.Delete("/api/bot/:id", deleteBot)              // удалить бота

		//websocket
		mw.e.WebSocket("/bots/ws", mw.websockDataBots) // вебсокет для динамического обновления информация по списку ботов

		// служебные вызовы на время разработки
		mw.e.Get("/api/bots/upd", mw.updateInfBots) // иницировать обновление информации в списке ботов

		//		TODO инициализация настроек сервера (ip с которых можно принимать запросы, порт и т.д.)
		mw.e.Run(":8080")
	}()

	return nil
}
Пример #20
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	fetchFeed()

	e := echo.New()
	e.Use(mw.Logger())
	e.Use(mw.Recover())
	e.Use(mw.StripTrailingSlash())
	e.Use(mw.Gzip())
	e.Use(cors.Default().Handler)

	bundle, _ := ioutil.ReadFile("./build/bundle.js")

	// stats
	s := stats.New()
	e.Use(s.Handler)
	e.Get("/stats", func(c *echo.Context) error {
		return c.JSON(http.StatusOK, s.Data())
	})
	// static files
	e.Static("/public/css", "public/css")
	e.Static("/universal.js", "./build/bundle.js")
	e.Favicon("public/favicon.ico")

	e.Get("/", selfjs.New(runtime.NumCPU(), string(bundle), rss))
	e.Get("/about", selfjs.New(runtime.NumCPU(), string(bundle), loremJSON()))

	e.Get("/api/data", apiFrontPage)
	e.Get("/api/anotherpage", apiAnotherPage)
	go tick()
	fmt.Println("serving at port 3000")
	e.Run(":3000")
}
Пример #21
0
func main() {
	e := echo.New()

	// Middleware
	e.Use(middleware.Logger())
	e.Use(middleware.Recover())

	// Login route
	e.POST("/login", login)

	// Unauthenticated route
	e.GET("/", accessible)

	// Restricted group
	r := e.Group("/restricted")

	// Configure middleware with the custom claims type
	config := middleware.JWTConfig{
		Claims:     &jwtCustomClaims{},
		SigningKey: []byte("secret"),
	}
	r.Use(middleware.JWTWithConfig(config))
	r.GET("", restricted)

	e.Logger.Fatal(e.Start(":1323"))
}
Пример #22
0
func main() {
	var err error
	// Echo instance
	e := echo.New()
	e.SetDebug(true)

	// Middleware
	e.Use(mw.Logger())
	e.Use(mw.Recover())

	con, err = sql.Open("mysql", "golang:golang@tcp(localhost:3306)/golang")
	if err != nil {
		log.Fatal(err)
	}

	data.InitDatabase(con)

	// createPosts(con)

	// Routes
	e.Get("/", hello)

	// Start server
	e.Run(":1323")
}
Пример #23
0
func main() {

	e := echo.New()
	e.Debug()

	//Midleware
	e.Use(mw.Logger())
	e.Use(mw.Recover())

	e.SetHTTPErrorHandler(func(err error, c *echo.Context) {
		log.Println(err)
		e.DefaultHTTPErrorHandler(err, c)
	})

	//Handlers
	e.Post("/Plugin.Activate", PluginActivate)
	e.Post("/NetworkDriver.CreateNetwork", NetworkDriverCreateNetwork)
	e.Post("/NetworkDriver.DeleteNetwork", NetworkDriverDeleteNetwork)
	e.Post("/NetworkDriver.CreateEndpoint", NetworkDriverCreateEndpoint)
	e.Post("/NetworkDriver.EndpointOperInfo", NetworkDriverEndpointOperInfo)
	e.Post("/NetworkDriver.DeleteEndpoint", NetworkDriverDeleteEndpoint)
	e.Post("/NetworkDriver.Join", NetworkDriverJoin)
	e.Post("/NetworkDriver.Leave", NetworkDriverLeave)

	e.Run(":1313")
}
Пример #24
0
func main() {
	// inti config and component
	componentInit()

	// Echo instance
	e := echo.New()

	// Middleware
	e.Use(mw.Logger())
	e.Use(mw.Recover())
	// e.Use(handler.CrossDomain)

	// Routes
	e.Get("/hello", handler.Hello)
	e.Get("/api/v1/seckill", handler.Tickets)
	e.Get("/api/v1/reset", handler.Reset)

	// go cache.StartUpdateEventStatus()

	// go kafka.StartKafkaProducer()
	// Start server
	port := viper.GetString("port")
	log.Println("server port: ", port)
	graceful.ListenAndServe(e.Server(port), 1*time.Second)

}
Пример #25
0
func main() {
	echo_serve := echo.New()

	mws := []echo.Middleware{mw.Logger(), mw.Recover(), mw.Gzip()}
	//注册日志、故障恢复、响应Gzip压缩中间件
	echo_serve.Use(mws...)

	//	echo_serve.Static("/","templates")
	//	echo_serve.Static("/js","sources/scripts")
	//	echo_serve.Static("/css","sources/css")
	//
	//	echo_serve.Index("templates/index.html")

	tmpl, err := template.ParseGlob("templates/*.html")
	if err != nil {
		fmt.Print(err.Error())
	}

	t := &Template{
		templates: template.Must(tmpl, err),
	}
	echo_serve.SetRenderer(t)
	echo_serve.Get("/hello", Hello)

	echo_serve.Run(":9060")
}
Пример #26
0
func server(config config, db *sql.DB) *echo.Echo {
	dbx := sqlx.NewDb(db, "postgres")
	exec := echo.New()
	if !config.Production {
		exec.Debug()
	}
	exec.Use(mw.Logger())
	exec.Use(mw.Recover())
	exec.Use(mw.Gzip())

	exec.Get("/status", func(c *echo.Context) error {
		return c.NoContent(http.StatusOK)
	})

	leadHandler := lead.NewHandler(datastores.NewLead(dbx))

	exec.Post("/lead", leadHandler.Create)
	exec.Get("/lead/:hashCode", leadHandler.CountByInvites)

	assetHandler := http.FileServer(rice.MustFindBox("static").HTTPBox())
	exec.Get("/", func(c *echo.Context) error {
		assetHandler.ServeHTTP(c.Response().Writer(), c.Request())
		return nil
	})
	exec.Get("/static/*", func(c *echo.Context) error {
		http.StripPrefix("/static/", assetHandler).
			ServeHTTP(c.Response().Writer(), c.Request())
		return nil
	})

	return exec
}
Пример #27
0
func BuildEcho() *echo.Echo {
	// ----------
	// Framework
	// ----------

	e := echo.New()

	// -----------
	// Middleware
	// -----------

	e.Use(echo_middleware.Logger())
	e.Use(middleware.Recover())

	// ------------
	// Controllers
	// ------------

	topicsController := new(controllers.TopicsController)

	// ----------
	// Endpoints
	// ----------

	e.Get("/topics", topicsController.Index)
	e.Get("/topics/:id", topicsController.Show)
	e.Post("/topics", topicsController.Create)
	e.Put("/topics/:id", topicsController.Update)
	e.Delete("/topics/:id", topicsController.Delete)

	return e
}
Пример #28
0
// setup prepares the internal HTTP handle, middleware, and resources.
func (s *Server) setup() {
	e := echo.New()
	s.core = e

	// Enable HTTP 2
	e.HTTP2(true)

	// Toggle debug
	e.SetDebug(s.Debug)

	// Setup middleware.
	e.Use(mw.Logger())
	e.Use(mw.Recover())
	e.Use(mw.Gzip())

	// Setup CORS.
	e.Use(cors.New(cors.Options{
		AllowedOrigins: s.AllowedHosts,
	}).Handler)

	// Add middleware for setting the server context.
	e.Use(s.serverContext)

	e.Get("/", httpRoot)
	e.Get("/domains", httpDomains)

	e.Get("/log/:domain", httpLog)
	e.Get("/log/:domain/entities", httpDomainEntities)
	e.Get("/log/:domain/attributes", httpDomainAttributes)
	e.Get("/log/:domain/values", httpDomainValues)

	e.Get("/timeline/:domain", httpTimeline)
}
Пример #29
0
func main() {
	serv := echo.New()
	serv.Use(middleware.Logger())
	serv.Use(middleware.Recover())
	// store := session.NewCookieStore([]byte("secret"))
	store, err := session.NewRedisStore(32, "tcp", "localhost:6379", "", []byte("secret"))
	if err != nil {
		panic(err)
	}
	serv.Use(session.Sessions("GSESSION", store))
	serv.Get("/", func(ctx echo.Context) error {
		session := session.Default(ctx)
		var count int
		v := session.Get("count")
		if v == nil {
			count = 0
		} else {
			count = v.(int)
			count += 1
		}
		session.Set("count", count)
		session.Save()
		ctx.JSON(200, map[string]interface{}{
			"visit": count,
		})
		return nil
	})
	serv.Run(standard.New(":8081"))
}
Пример #30
-1
func main() {
	e := echo.New()
	e.Use(middleware.Logger())
	e.Use(middleware.Recover())
	e.Use(middleware.Static("../public"))
	e.GET("/ws", standard.WrapHandler(http.HandlerFunc(hello())))
	e.Run(standard.New(":1323"))
}