目录
目录README.md

Perfect Web Redirects

Get Involed with Perfect!

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

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

Perfect Web Redirects Demo

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

A demo showing the usage, and working of the Perfect WebRedirects module can be found at https://github.com/PerfectExamples/Perfect-WebRedirects-Demo.

Including in your project

Import the dependency into your project by specifying it in your project’s Package.swift file, or adding it via Perfect Assistant.

.Package(url: "https://github.com/PerfectlySoft/Perfect-WebRedirects", majorVersion: 3),

Then in your main.swift file where you configure your web server, add it as an import, and add the filter:

import PerfectWebRedirects

Adding the filter:

// Add to the "filters" section of the config:
[
    "type":"request",
    "priority":"high",
    "name":WebRedirectsFilter.filterAPIRequest,
]

If you are also adding Request Logger filters, if the Web Redirects object is added second, directly after the RequestLogger filter, then both the original request (and it’s associated redirect code) and the new request, will be logged correctly.

Configuration file

The configuration for the routes is included in JSON files at /config/redirect-rules/*.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 9 or the Swift 4 toolchain on Ubuntu.

Further Information

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

关于
42.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号