SyliusResourceBundle icon indicating copy to clipboard operation
SyliusResourceBundle copied to clipboard

Not possible to set your own response by an event for non-HTML requests

Open pamil opened this issue 6 years ago • 0 comments

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Sylius version 1.0.0

ResouceController:

if ($event->isStopped() && !$configuration->isHtmlRequest()) {
    throw new HttpException($event->getErrorCode(), $event->getMessage());
}
if ($event->isStopped()) {
    $this->flashHelper->addFlashFromEvent($configuration, $event);

    if ($event->hasResponse()) {
        return $event->getResponse();
    }

    return $this->redirectHandler->redirectToResource($configuration, $resource);
}

It should be possible to set your own response for non-HTML requests.

pamil avatar Oct 12 '17 09:10 pamil

Yeah, this is pretty reasonable. However, there are a lot of whitespace changes. I just added cljfmt to the project, can you merge with my changes, and run lein cljfmt on yours? Thanks.

ztellman avatar Feb 26 '15 22:02 ztellman

Is there anything else you would like me to do for this PR?

shmish111 avatar Mar 02 '15 12:03 shmish111

Also, I'm using https://github.com/hozumi/clj-det-enc locally to detect the character encoding, would you mind if I added that here? The issue being it's another dependency for the project...

shmish111 avatar Mar 02 '15 15:03 shmish111

I'd prefer it be an optional dependency like the others, if possible.

ztellman avatar Mar 02 '15 19:03 ztellman

Actually, looking at that code, I'm not sure how it works with HTTP requests, since it'll consume the head of the InputStream. Can you expand on how that would be used here?

ztellman avatar Mar 02 '15 19:03 ztellman

I've added the code to the PR. It does mean you have to specify if you want an InputStream, rather than being the default.

shmish111 avatar Mar 03 '15 21:03 shmish111

I'd honestly prefer it be left out. If it belongs anywhere, it belongs in byte-streams. Let me give it some thought.

ztellman avatar Mar 03 '15 21:03 ztellman

Indeed it would be nice in bs/to-string, I want that function to do as much for me as possible. Would it adversely affect performance though? If so it could be an option :detect true... Also, I think I will change the default coercion to be none at all and require :as :string if you want a String. What do you think?

shmish111 avatar Mar 04 '15 08:03 shmish111

Yes, I'd prefer no coercion to be the default. On Mar 4, 2015 12:25 AM, "David Smith" [email protected] wrote:

Indeed it would be nice in bs/to-string, I want that function to do as much for me as possible. Would it adversely affect performance though? If so it could be an option :detect true... Also, I think I will change the default coercion to be none at all and require :as :string if you want a String. What do you think?

— Reply to this email directly or view it on GitHub https://github.com/ztellman/aleph/pull/154#issuecomment-77115452.

ztellman avatar Mar 04 '15 08:03 ztellman