Akka HTTP重定向错误

时间:2017-08-01 07:14:00

标签: scala akka-http

我正在使用Akka-HTTP。我有以下URI

  

/ a

     

/ B

我将在/a URI上收到HIT,并且在满足条件时我有条件然后我想重定向到/b URI

如果不满足该条件,那么我将返回BAD REQUEST

现在问题在于Akka-HTTP重定向URI是标准路由类型,我想返回HTTP响应,因为我无法运行代码。

有谁能告诉我如何在Akka-HTTP中使用HTTP Response类型重定向?

1 个答案:

答案 0 :(得分:0)

要在Akka-HTTP中从一个URI重定向到另一个URI,我们可以使用相同的HTTP响应类型。

  

HttpResponse(status = StatusCodes.PermanentRedirect,             headers = headers.Location(Uri(" URI /结束点Akka-http重定向")):: Nil,             entity = response)

此方法会将传入请求重定向到标头@echo off set "VERSION=%1" set "COMMON_VERSION=%2" if "%VERSION%"=="" set /p VERSION=Enter the version number you want to create the branch for?: if "%COMMON_VERSION%"=="" set /p COMMON_VERSION=Enter the version number of the common python toolchain you want to use?: set PACKAGE_NAME=%~dp0 ECHO ##### Updating SVN Repository svn update ECHO ##### Creating requirements.txt cd trunk call python create_requirements_txt.py %VERSION% %COMMON_VERSION% svn add requirements.txt svn commit requirements.txt -m "Updated requirements.txt to version %VERSION%" cd %~dp0 ECHO ##### Creating Branch for version %VERSION% for /f "delims=" %%i in ('svn info ^| FINDSTR /R /C:"Relative URL"') do set URL=%%i set "URL=%URL:*: =%" for /f "delims=" %%i in ('svn info ^| FINDSTR /R /C:"Repository Root"') do set ROOT=%%i set "ROOT=%ROOT:*: =%" set "DEST_URL=%ROOT%%URL:*\trunk=%/branches/%VERSION%" set "SRC_URL=%ROOT%%URL%/trunk" ECHO ##### Package: %PACKAGE_NAME% ECHO ##### Source: %SRC_URL% ECHO ##### Destination: %DEST_URL% call svn copy %SRC_URL% %DEST_URL% -m "Branch %PACKAGE_NAME% Version %VERSION%" ECHO ##### Succesfully created branch %VERSION% call svn update ECHO ##### Creating Docs Branch %VERSION% cd %~dp0\trunk\Python\MyPackage\docs call make html cp -r _build\html %~dp0\branches\%VERSION%\Python\docs\MyPackage svn add %~dp0\branches\%VERSION%\Python\docs\MyPackage svn commit %~dp0\branches\%VERSION%\Python\docs\MyPackage -m "Added Docs Branch %VERSION%" pause exit /b 0 :SVN_ERROR ECHO ##### SVN Error: Either Source Repo (%SRC_URL%) does not exist or the Tag (%DEST_URL%) already exists! pause exit /b 1 部分中提供的URI。

由于