Comments (11)
Needs some checking with the spec IMO.
Not sure relativePath
is correct, would be absolutePath
right?
Perhaps require it should start with /
(or protocol) then?
from akka-http.
We can add the matched path logic to RequestContext
as requested in akka/akka#15839. What would be left is a simple respondWithHeader(Location(...))
which doesn't warrant its own directive IMO.
from akka-http.
FTR: Extracting the matched path is already implemented and hidden inside FileAndResourceDirectives#listDirectoryContents
.
from akka-http.
@ktoso @2Beaucoup I could dance with this one, but it seems obsolete - based on akka/akka#15839. Can we establish if respondWithLocation
is to be added?
from akka-http.
IMO: No. What do others think?
from akka-http.
Well my use case still exists: we want to send a server-root relative Location:
back as part of a "POST to create resource" pattern, i.e.
POST /resources
201 Created
Location: /resources/42
without needing to repeat "/resources"
in the routing logic.
from akka-http.
@jypma What do you think about #6 (comment)?
from akka-http.
You'd still need to combine two directives. Assuming ctx.getMatchedPath()
returns Uri
:
extractRequestContext(ctx ->
respondWithHeader(Location.create(ctx.getMatchedPath().addPathSegment(myId)), () ->
complete(...)
)
)
It would reduce the custom code for sure, so it would be a definite improvement.
I'd personally still push it down into a respondWithLocation
directive in my own code though... but if I'm the only one having this API style, it's obviously not much of a pattern :)
from akka-http.
I'm with @2Beaucoup on this one. Adding matchedPath
to RequestContext
(only necessary if we want to keep it as a field in RequestContext) or as a directive would be a definite win.
For which kind of responses do you want to add Location
headers, @jypma? The redirection ones or 201
or something else?
from akka-http.
@jrudolph It's a 201 Created. Sorry, edited 2 comments ago to reflect that. So client POSTs a new resource to us, with the content in the body, server then makes up an identifier for that new resource, and returns its new location in the Location:
header, which happens to always be directly underneath the URI that the original POST goes to.
Either way, just getting matchedPath
would be an improvement, so by all means let's go forward with that. As long as Uri.addPathSegment
would properly handle the current matchedPath
ending or not ending in a slash.
from akka-http.
I added #496 to track the matched path feature. Let's close this for now.
from akka-http.
Related Issues (20)
- Cannot Unmarshall Seq[String] Outside HOT 1
- Release 10.6.0-M1
- Release 10.6.0-M2
- CVE-2023-44487 HOT 3
- Release 10.5.3
- Release 10.6.0
- Failed: Http2ClientSpec should send RST_STREAM if entity stream is canceled HOT 2
- Failed: Http2ServerSpec send RST_STREAM if entity stream is canceled
- Remove dependency on `sbt-dependency-graph` HOT 1
- Release 10.6.1
- Failed: Native image tests HOT 1
- SSE (and maybe more) marshalling/unmarshalling require classic system HOT 1
- fail: CI is failing to publish docs HOT 2
- The akka.http.cors package is not exist HOT 1
- Release 10.6.2
- failed: JwtDirectivesSpec HOT 4
- Failed: OutOfMemoryError HOT 1
- Release 10.6.3 HOT 1
- Explicit typed actor system to Http.apply does not compile on Scala 3
- `Content-Disposition` header parsing for `form-data` doesn't follow RFC7578 HOT 1
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 akka-http.