mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 04:54:04 -08:00
Better way to redirect entirely from /w/docs/javadoc to new github.io site
This commit is contained in:
parent
c1df162b95
commit
8ae5c0f5bc
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.zxing.web;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.net.HttpHeaders;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
public final class LegacyJavadocRedirectServlet extends HttpServlet {
|
||||||
|
|
||||||
|
private static final String PREFIX = "/w/docs/javadoc/";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
String requestURI = request.getRequestURI();
|
||||||
|
Preconditions.checkArgument(requestURI.startsWith(PREFIX));
|
||||||
|
String redirectURI = "http://zxing.github.io/zxing/apidocs/" + requestURI.substring(PREFIX.length());
|
||||||
|
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
||||||
|
response.setHeader(HttpHeaders.LOCATION, redirectURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -37,6 +37,11 @@
|
||||||
<servlet-class>com.google.zxing.web.ChartServlet</servlet-class>
|
<servlet-class>com.google.zxing.web.ChartServlet</servlet-class>
|
||||||
<load-on-startup>1</load-on-startup>
|
<load-on-startup>1</load-on-startup>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>LegacyJavadocRedirectServlet</servlet-name>
|
||||||
|
<servlet-class>com.google.zxing.web.LegacyJavadocRedirectServlet</servlet-class>
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>DecodeServlet</servlet-name>
|
<servlet-name>DecodeServlet</servlet-name>
|
||||||
|
@ -46,6 +51,10 @@
|
||||||
<servlet-name>ChartServlet</servlet-name>
|
<servlet-name>ChartServlet</servlet-name>
|
||||||
<url-pattern>/w/chart</url-pattern>
|
<url-pattern>/w/chart</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>LegacyJavadocRedirectServlet</servlet-name>
|
||||||
|
<url-pattern>/w/docs/javadoc/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>index.jspx</welcome-file>
|
<welcome-file>index.jspx</welcome-file>
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Redirect</title>
|
|
||||||
<meta http-equiv="Refresh" content="0;url=http://zxing.github.io/zxing/apidocs/index.html"/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in a new issue