Skip to content

PerfectExamples/Perfect-WebRedirects-Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perfect Web Redirects Demo

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 3.0 Platforms OS X | Linux License Apache PerfectlySoft Twitter Slack Status

Perfect Web Redirects Demo

This demo shows the usage, and working of the Perfect WebRedirects module.

The Perfect WebRedirects module will filter for specified routes (including trailing wildcard routes) and perform redirects as instructed if a match is found.

Configuration file

The configuration for these routes is included in a JSON file at /config/redirect-rules/config.json in the form:

{

  "/test/no": {
	"code": 302,
	"destination": "/test/yes"
  },

	"/test/no301": {
		"code": 301,
		"destination": "/test/yes"
  },
  
	"/test/wild/*": {
		"code": 302,
		"destination": "/test/wildyes"
  },

	"/test/wilder/*": {
		"code": 302,
		"destination": "/test/wilding/*"
  }

}

Note that multiple JSON files can exist in this directory - all will be loaded the first time the filter is invoked.

Compatibility with Swift

The master branch of this project currently compiles with Xcode 8.2 or the Swift 3.0.2 toolchain on Ubuntu.

Building & Running

The following will clone and build an empty starter project and launch the server on port 8181.

git clone https://github.com/PerfectExamples/Perfect-WebRedirects-Demo.git
cd Perfect-WebRedirects-Demo
swift build
.build/debug/Perfect-WebRedirects-Demo

You should see the following output:

[INFO] Starting HTTP server localhost on 0.0.0.0:8181

This means the servers are running and waiting for connections. Access http://localhost:8181/ to see the greeting. Hit control-c to terminate the server.

NOTE: If run from within Xcode, please make sure that the executable target has the appropriate "working directory" specified, otherwise the config file will not be found and the demo will fail to work as intended.

Testing Functionality

in the browser, http://localhost:8181 will display the current route plus four links, two of which have random strings to demonstrate wildcard behaviour.

Click the links and see the behaviour - the redirects with the appropriate 302 or 302 HTTP status code will be performed as specified in the configuration file.

Issues

We are transitioning to using JIRA for all bugs and support related issues, therefore the GitHub issues has been disabled.

If you find a mistake, bug, or any other helpful suggestion you'd like to make on the docs please head over to http://jira.perfect.org:8080/servicedesk/customer/portal/1 and raise it.

A comprehensive list of open issues can be found at http://jira.perfect.org:8080/projects/ISS/issues

Further Information

For more information on the Perfect project, please visit perfect.org.

About

This demo shows the usage, and working of the Perfect WebRedirects module.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages