GithubHelp home page GithubHelp logo

Comments (4)

tindzk avatar tindzk commented on May 28, 2024

Thanks for the issue, @aappddeevv! I agree this is a useful feature. It revealed some insufficiencies in Trail's current design. Ideally, static path elements should not be encoded in the type parameter at all, only the placeholders (like Arg[String] or Fragment[Int]).

I have explored some ways to simplify the design and found a way to model the current functionality with tuples instead of HLists. Could you try out #29 and let me know your thoughts?

With the changes, you could express conditional routes as follows:

class Routes(isProduction: Boolean) {
  val root  = if (isProduction) Root / "api" / "v2.0" else Root
  val users = root / "users" / Arg[String]
}

val devRoutes  = new Routes(isProduction = false)
val prodRoutes = new Routes(isProduction = true)

assert(devRoutes.users.parse("/users/test").contains("test"))
assert(prodRoutes.users.parse("/api/v2.0/users/test").contains("test"))

from trail.

aappddeevv avatar aappddeevv commented on May 28, 2024

Do I need to try this with a local build? Or did you push something out to the repos?

Whoops, just saw the tag.

from trail.

aappddeevv avatar aappddeevv commented on May 28, 2024

So far its working. Ideally you could always change the server routing but that's not always possible e.g. static website server.

from trail.

tindzk avatar tindzk commented on May 28, 2024

Great, thanks for testing!

from trail.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.