Example #1
0
func main() {

	log.Debug("Starting server...")

	m := macaron.Classic()
	m.Use(macaron.Renderer())
	m.Use(rest.AuthMiddleWare())
	m.Get("/", func(c *macaron.Context, as rest.AuthService) string {
		token, _ := as.GenSysToken(c.RemoteAddr(), 15)
		return token
	})

	m.Run("0.0.0.0", 8081)
}
Example #2
0
File: init.go Project: wcreate/wuc
func InitHandles(m *macaron.Macaron) {
	m.Use(rest.AuthMiddleWare())

	initCaptch(m)
	m.Get("/captcha/new", handler.GetCaptcha)

	m.Post("/api/user/signup", handler.AddUser)
	m.Delete("/api/user/:uid", handler.DeleteUser)

	m.Get("/api/user/info/:uid", handler.UserInfo)
	m.Put("/api/user/info/:uid", handler.ModifyUser)
	m.Post("/api/user/info/:uid", handler.ModifyUser)
	m.Put("/api/user/pwd/:uid", handler.ModifyPassword)
	m.Put("/api/user/email/:uid", handler.ModifyEmail)

	m.Post("/api/user/login", handler.LoginUser)
	m.Post("/api/user/logout", handler.LogoutUser)

	m.Get("/api/user/check", handler.CheckUser)
	m.Get("/user/cfm", handler.ConfirmUser) // note: not need start with /api

	m.Post("/api/user/avatar/:uid", handler.UploadAvatar)
}