Ejemplo n.º 1
0
// Define routes for this app
func setupRoutes(r *router.Router) {

	// Set the default file handler
	r.FileHandler = fileHandler
	r.ErrorHandler = errHandler

	// Add a files route to handle static images under files
	// - nginx deals with this in production - perhaps only do this in dev?
	r.Add("/files/{path:.*}", fileHandler)
	r.Add("/favicon.ico", fileHandler)

	// Add the home page route
	r.Add("/", homeHandler)

}
Ejemplo n.º 2
0
// Define routes for this app
func setupRoutes(r *router.Router) {

	// Set the default file handler
	r.FileHandler = fileHandler
	r.ErrorHandler = errHandler

	// Add the home page route
	r.Add("/", storyactions.HandleHome)
	r.Add("/index{format:(.xml)?}", storyactions.HandleIndex)
	r.Add("/stories/create", storyactions.HandleCreateShow)
	r.Add("/stories/create", storyactions.HandleCreate).Post()
	r.Add("/stories/code{format:(.xml)?}", storyactions.HandleCode)
	r.Add("/stories/upvoted{format:(.xml)?}", storyactions.HandleUpvoted)
	r.Add("/stories/{id:[0-9]+}/update", storyactions.HandleUpdateShow)
	r.Add("/stories/{id:[0-9]+}/update", storyactions.HandleUpdate).Post()
	r.Add("/stories/{id:[0-9]+}/destroy", storyactions.HandleDestroy).Post()
	r.Add("/stories/{id:[0-9]+}/upvote", storyactions.HandleUpvote).Post()
	r.Add("/stories/{id:[0-9]+}/downvote", storyactions.HandleDownvote).Post()
	r.Add("/stories/{id:[0-9]+}/flag", storyactions.HandleFlag).Post()
	r.Add("/stories/{id:[0-9]+}", storyactions.HandleShow)
	r.Add("/stories{format:(.xml)?}", storyactions.HandleIndex)

	r.Add("/comments", commentactions.HandleIndex)
	r.Add("/comments/create", commentactions.HandleCreateShow)
	r.Add("/comments/create", commentactions.HandleCreate).Post()
	r.Add("/comments/{id:[0-9]+}/update", commentactions.HandleUpdateShow)
	r.Add("/comments/{id:[0-9]+}/update", commentactions.HandleUpdate).Post()
	r.Add("/comments/{id:[0-9]+}/destroy", commentactions.HandleDestroy).Post()
	r.Add("/comments/{id:[0-9]+}/upvote", commentactions.HandleUpvote).Post()
	r.Add("/comments/{id:[0-9]+}/downvote", commentactions.HandleDownvote).Post()
	r.Add("/comments/{id:[0-9]+}/flag", commentactions.HandleFlag).Post()
	r.Add("/comments/{id:[0-9]+}", commentactions.HandleShow)

	r.Add("/users", useractions.HandleIndex)
	r.Add("/users/create", useractions.HandleCreateShow)
	r.Add("/users/create", useractions.HandleCreate).Post()
	r.Add("/users/{id:[0-9]+}/update", useractions.HandleUpdateShow)
	r.Add("/users/{id:[0-9]+}/update", useractions.HandleUpdate).Post()
	r.Add("/users/{id:[0-9]+}/destroy", useractions.HandleDestroy).Post()
	r.Add("/users/{id:[0-9]+}", useractions.HandleShow)
	r.Add("/users/login", useractions.HandleLoginShow)
	r.Add("/users/login", useractions.HandleLogin).Post()
	r.Add("/users/logout", useractions.HandleLogout).Post()

	// Add a files route to handle static images under files
	// - nginx deals with this in production - perhaps only do this in dev?
	r.Add("/files/{path:.*}", fileHandler)
	r.Add("/favicon.ico", fileHandler)

}
Ejemplo n.º 3
0
// Define routes for this app
func setupRoutes(r *router.Router) {

	// Set the default file handler
	r.FileHandler = fileHandler
	r.ErrorHandler = errHandler

	// Add a files route to handle static images under files
	// - nginx deals with this in production - perhaps only do this in dev?
	r.Add("/files/{path:.*}", fileHandler)
	r.Add("/favicon.ico", fileHandler)

	// Add the home page route
	r.Add("/", pageactions.HandleHome)

	r.Add("/blog", postactions.HandleBlog)
	r.Add("/posts", postactions.HandleIndex)
	r.Add("/posts/create", postactions.HandleCreateShow)
	r.Add("/posts/create", postactions.HandleCreate).Post()
	r.Add("/posts/{id:[0-9]+}/update", postactions.HandleUpdateShow)
	r.Add("/posts/{id:[0-9]+}/update", postactions.HandleUpdate).Post()
	r.Add("/posts/{id:[0-9]+}/destroy", postactions.HandleDestroy).Post()
	r.Add("/posts/{id:[0-9]+}", postactions.HandleShow)

	// Standard REST handlers for tags
	r.Add("/tags", tagactions.HandleIndex)
	r.Add("/tags/create", tagactions.HandleCreateShow)
	r.Add("/tags/create", tagactions.HandleCreate).Post()
	r.Add("/tags/{id:[0-9]+}/update", tagactions.HandleUpdateShow)
	r.Add("/tags/{id:[0-9]+}/update", tagactions.HandleUpdate).Post()
	r.Add("/tags/{id:[0-9]+}/destroy", tagactions.HandleDestroy).Post()
	r.Add("/tags/{id:[0-9]+}", tagactions.HandleShow)

	// Standard REST handlers for users
	r.Add("/users", useractions.HandleIndex)
	r.Add("/users/create", useractions.HandleCreateShow)
	r.Add("/users/create", useractions.HandleCreate).Post()
	r.Add("/users/{id:[0-9]+}/update", useractions.HandleUpdateShow)
	r.Add("/users/{id:[0-9]+}/update", useractions.HandleUpdate).Post()
	r.Add("/users/{id:[0-9]+}/destroy", useractions.HandleDestroy).Post()
	r.Add("/users/{id:[0-9]+}", useractions.HandleShow)
	r.Add("/users/login", useractions.HandleLoginShow)
	r.Add("/users/login", useractions.HandleLogin).Post()
	r.Add("/users/logout", useractions.HandleLogout).Post()
	r.Add("/users/password", useractions.HandlePasswordReset).Post()
	r.Add("/users/password/reset", useractions.HandlePasswordResetShow)
	r.Add("/users/password/reset", useractions.HandlePasswordResetSend).Post()
	r.Add("/users/password/sent", useractions.HandlePasswordResetSentShow)

	// Standard REST handlers for pages
	r.Add("/pages", pageactions.HandleIndex)
	r.Add("/pages/create", pageactions.HandleCreateShow)
	r.Add("/pages/create", pageactions.HandleCreate).Post()
	r.Add("/pages/{id:[0-9]+}/update", pageactions.HandleUpdateShow)
	r.Add("/pages/{id:[0-9]+}/update", pageactions.HandleUpdate).Post()
	r.Add("/pages/{id:[0-9]+}/destroy", pageactions.HandleDestroy).Post()
	r.Add("/pages/{id:[0-9]+}", pageactions.HandleShow)

	// Setup for an empty website
	r.Add("/fragmenta/setup", pageactions.HandleShowSetup)
	r.Add("/fragmenta/setup", pageactions.HandleSetup).Post()

	// Final wildcard route for pages
	r.Add("/{path:[a-z0-9]+}", pageactions.HandleShowPath)

}
Ejemplo n.º 4
0
// Define routes for this app
func setupRoutes(r *router.Router) {

	r.Add("/users", useractions.HandleIndex)
	r.Add("/users/create", useractions.HandleCreateShow)
	r.Add("/users/create", useractions.HandleCreate).Post()
	r.Add("/users/login", useractions.HandleLoginShow)
	r.Add("/users/login", useractions.HandleLogin).Post()
	r.Add("/users/logout", useractions.HandleLogout).Post()
	r.Add("/users/{id:[0-9]+}/update", useractions.HandleUpdateShow)
	r.Add("/users/{id:[0-9]+}/update", useractions.HandleUpdate).Post()
	r.Add("/users/{id:[0-9]+}/destroy", useractions.HandleDestroy).Post()
	r.Add("/users/{name:.+}/key", useractions.HandleShowKey)
	r.Add("/users/{id:[0-9]+}", useractions.HandleShow)
	r.Add("/users/{name:.+}", useractions.HandleShowName)

	r.Add("/pages", pageactions.HandleIndex)
	r.Add("/pages/create", pageactions.HandleCreateShow)
	r.Add("/pages/create", pageactions.HandleCreate).Post()
	r.Add("/pages/{id:[0-9]+}/update", pageactions.HandleUpdateShow)
	r.Add("/pages/{id:[0-9]+}/update", pageactions.HandleUpdate).Post()
	r.Add("/pages/{id:[0-9]+}/destroy", pageactions.HandleDestroy).Post()
	r.Add("/pages/{id:[0-9]+}", pageactions.HandleShow)

	r.Add("/files", fileactions.HandleIndex)
	r.Add("/files/create", fileactions.HandleCreate).Post()
	r.Add("/files/{id:[0-9]+}/update", fileactions.HandleUpdateShow)
	r.Add("/files/{id:[0-9]+}/update", fileactions.HandleUpdate).Post()
	r.Add("/files/{id:[0-9]+}/destroy", fileactions.HandleDestroy).Post()
	r.Add("/files/{id:[0-9]+}/download", fileactions.HandleDownload)

	// Set the default file handler
	r.FileHandler = fileHandler
	r.ErrorHandler = errHandler

	r.Add("/favicon.ico", fileHandler)

	// Add the custom page route
	r.Add("/{path:[a-z0-9]?}", pageactions.HandleShowPath)

}