Comments (5)
Agreed.
It was on a todo list of mine somewhere as I was in the process of removing dependencies over the last few releases.
Just as a counter point EExHTML
is a very small dependency. Will escaping even this small piece require a general purpose html escape function, i.e. very similar to the one in EExHTML
from raxx.
One could also argue that a redirect with a HTML body is not in the scope of Raxx after Raxx.View has been extracted (I guess to make Raxx more general purpose?).
Perhaps it would be an idea to change redirect/2
to not include a body by default, but to make it configurable to do so. Something like this:
@spec redirect(String.t(), status: status, body: String.t(), content_type: String.t()) :: Raxx.Response.t()
def redirect(url, opts \\ []) do
status = Keyword.get(opts, :status, :see_other)
response = status |> response() |> set_header("location", url)
case Keyword.fetch(opts, :body) do
{:ok, body} ->
content_type = Keyword.fetch!(opts, :content_type)
response
|> set_header("content-type", content_type)
|> set_body(body)
:error ->
response
end
end
from raxx.
Good answer, because it's fair enough to point out that the HTML body is useless if creating an API service.
from raxx.
I can make a PR if you'd like that :)
from raxx.
That would be lovely 👍
from raxx.
Related Issues (20)
- Add middleware proof of concept HOT 10
- Remove handle_request from Raxx.Server behaviour HOT 2
- Should setting a body on a GET request raise an error. HOT 1
- Benchmark different Raxx.Stack state structures and switch to the fastest one HOT 1
- Add a Middleware-aware Router HOT 5
- make `use Raxx.Middleware` a thing HOT 2
- Feature Proposal: Raxx.Context HOT 3
- allow to set multiple cookies HOT 5
- New 1.0 roadmap HOT 11
- Handle unexpected HTTP verb HOT 6
- Incorrect parsing of request when path looks like an absolute url HOT 1
- Raxx.Session 1.0 Roadmap
- Raxx.View 1.0 Roadmap
- Raxx.Logger 1.0 Roadmap
- can we have both server streaming and simple request/response in same module?
- Fix specs, to show that Raxx.data can contain iodata
- Gleam HOT 6
- Raxx.View add a way to have page metadata in the layout
- Project status? 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 raxx.