Coder Social home page Coder Social logo

Remove eex_html dep? about raxx HOT 5 CLOSED

lasseebert avatar lasseebert commented on June 1, 2024
Remove eex_html dep?

from raxx.

Comments (5)

CrowdHailer avatar CrowdHailer commented on June 1, 2024

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.

lasseebert avatar lasseebert commented on June 1, 2024

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.

CrowdHailer avatar CrowdHailer commented on June 1, 2024

Good answer, because it's fair enough to point out that the HTML body is useless if creating an API service.

from raxx.

lasseebert avatar lasseebert commented on June 1, 2024

I can make a PR if you'd like that :)

from raxx.

CrowdHailer avatar CrowdHailer commented on June 1, 2024

That would be lovely 👍

from raxx.

Related Issues (20)

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.