Comments (4)
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 HList
s. 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.
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.
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.
Great, thanks for testing!
from trail.
Related Issues (17)
- Some architectural improvements HOT 6
- Get rid of casts
- Query parameters HOT 3
- Cast needed when calling `url` on root node
- Design a DSL
- Scala Native support
- doc link is broken in README.md HOT 1
- bump in dependencies to get cats to above 1.0 HOT 1
- Support hash routing HOT 1
- Reduce url string parsing burden HOT 4
- Akka support
- Routes match more than advertised HOT 2
- Scala.js 1.0 support
- Write manual
- Match error for 3 or more Params HOT 2
- Long arguments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trail.