Giter Site home page Giter Site logo

Comments (10)

daviddenton avatar daviddenton commented on June 14, 2024

So this currently isn't possible without digging down into the guts and changing the definition of SSE. Looking at it, I think it is probably required. What you can do is to change the SSE handler at the server level (but that isn't a great solution TBH)

from http4k.

daviddenton avatar daviddenton commented on June 14, 2024

We've got an idea, and looking at what to do to make sure it's testable. It's going to be a breaking change whatever happens if we want to support it. For the time being, if you need to rewrite the underlying server-level handler that's the only way. Stay tuned :)

from http4k.

staklau avatar staklau commented on June 14, 2024

@daviddenton Thank you for the fast response.
What does it mean to rewrite the underlying server-level handler, exactly?

from http4k.

daviddenton avatar daviddenton commented on June 14, 2024

Well, assuming you are using Jetty, it would involve creating your own version of the server-backend and explicitly: JettyEventStreamHandler. This is pretty horrid TBH and would only work if you really want to set a standard set of headers for every SSE request

from http4k.

daviddenton avatar daviddenton commented on June 14, 2024

We think we have an idea of the type of change that might be required - we'll keep you posted

from http4k.

staklau avatar staklau commented on June 14, 2024

@daviddenton Then I'll stay put for now :)

from http4k.

daviddenton avatar daviddenton commented on June 14, 2024

We've managed to fix this and are releasing the changes as a part of 5.1.0.0 :)

from http4k.

staklau avatar staklau commented on June 14, 2024

@daviddenton Great, thanks! :)

from http4k.

staklau avatar staklau commented on June 14, 2024

@daviddenton Hi! I thought this was solved but when I'm trying to create a CORS-filter with the SseFilter I'm not allowed to set any headers for the response, ref:

  val corsFilter = SseFilter { next ->
    { request ->
      val response = next(request)
      response.header("Access-Control-Allow-Origin", "*") <-- the .header method does not exist
      response
    }
  }

Let me know If I'm missing something.

from http4k.

staklau avatar staklau commented on June 14, 2024

@daviddenton Ah nevermind I forgot about the copy method, ref:
response.copy(headers = listOf("Access-Control-Allow-Origin" to "*"))

from http4k.

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.