Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8385481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:40:57+00:00 2026-06-09T17:40:57+00:00

In play 1.x you had the http.path param which allowed you to set a

  • 0

In play 1.x you had the http.path param which allowed you to set a url to add to every route

http.param

How can I achieve someting similar in play 2.0?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:40:59+00:00Added an answer on June 9, 2026 at 5:40 pm

    I asked at play’s discussion group and they helped me achieve this initial version

    I create a PrefixedRequest like this

    import play.api.mvc.RequestHeader
    import play.api.Play.configuration
    
    import play.api.Play.current
    
    class PrefixedRequest(request: RequestHeader) extends RequestHeader {
    
        def headers = request.headers
        def queryString = request.queryString
    
        // strip first part of path and uri if it matches http.path config
        def path = ("^" + prefix).r.replaceFirstIn(request.path, "/")
        def uri = ("^" + prefix).r.replaceFirstIn(request.uri, "/")
    
        def method = request.method
        def remoteAddress = request.remoteAddress
    
        lazy val prefix = {
          val config = configuration.getString("http.path").getOrElse("")
          if (config.endsWith("/")) config else config + "/"
      }
    }
    
    object PrefixedRequest {
      def apply(request: RequestHeader) = new PrefixedRequest(request)
    }
    

    Then I used it in Global.scala

    import play.api.GlobalSettings
    import play.api.mvc.RequestHeader
    import play.api.mvc.Handler
    
    object Global extends GlobalSettings {
    
      override def onRouteRequest(request: RequestHeader): Option[Handler] = {
        super.onRouteRequest(PrefixedRequest(request))
      }
    
    }
    

    finnally added this to application.conf

    http.path=/prefix/
    

    It seems to work, but I couln’t find out how to add that prefix to the reversed routes… can anybody gimme a hand on that part?

    —

    Some useful links

    Check this thread and the docs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I play two or more audio file in Android? I had created
I have a Play! 1.2.4 app which is not playing nice. I can run
Seems like just yesterday I had this same problem with Play! v1. After trying
I really like Play 2.0's form mapping system, but I had a question about
Play tutorial shows a way to bind dynamic parameter to URL: GET /clients/:id controllers.Clients.show(id:
Play with it here: http://jsbin.com/ocicu4/4/edit Simple Accordion, I only want one section open at
I had developed a mobile page by asp.net to play mp4 video. I know
Has anyone had any luck getting encrypted streaming to work with Apple's HTTP Live
An interlinear gloss can be used to layout a translation of a document. http://en.wikipedia.org/wiki/Interlinear_gloss
In my application, I have an activity play http live streaming video in landscape

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.