mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-01 13:37:46 +00:00
WIP add devs files for working with caddy / mercure
This commit is contained in:
parent
def75cec6c
commit
3aea3f502b
@ -36,5 +36,5 @@ services:
|
||||
###> symfony/mercure-bundle ###
|
||||
mercure:
|
||||
ports:
|
||||
- "127.0.0.1:8080:80"
|
||||
- "127.0.0.1:8043:443"
|
||||
###< symfony/mercure-bundle ###
|
||||
|
@ -61,7 +61,7 @@ services:
|
||||
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||
# Set the URL of your Symfony project (without trailing slash!) as value of the cors_origins directive
|
||||
MERCURE_EXTRA_DIRECTIVES: |
|
||||
cors_origins http://127.0.0.1:8000
|
||||
cors_origins http://chill-bundles.wip https://chill-bundles.wip
|
||||
# Comment the following line to disable the development mode
|
||||
command: /usr/bin/caddy run --config /etc/caddy/dev.Caddyfile
|
||||
healthcheck:
|
||||
|
@ -17,3 +17,8 @@ when@dev:
|
||||
defaults:
|
||||
template: '@ChillMain/Dev/dev.assets.test2.html.twig'
|
||||
|
||||
dev_mercure:
|
||||
path: /_dev/mercure
|
||||
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
|
||||
defaults:
|
||||
template: '@ChillMain/Dev/dev.mercure.html.twig'
|
||||
|
20
resources/dev.Caddyfile
Normal file
20
resources/dev.Caddyfile
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
# Désactive les redirections automatiques HTTP -> HTTPS
|
||||
# auto_https off
|
||||
# Désactive le port 80 par défaut
|
||||
# default_bind :8080
|
||||
}
|
||||
|
||||
localhost:8043 {
|
||||
mercure {
|
||||
# Publisher JWT key
|
||||
publisher_jwt !ChangeThisMercureHubJWTSecretKey!
|
||||
# Subscriber JWT key
|
||||
subscriber_jwt !ChangeThisMercureHubJWTSecretKey!
|
||||
cors_origins http://chill-bundles.wip https://chill-bundles.wip
|
||||
ui
|
||||
demo
|
||||
}
|
||||
|
||||
respond "Not Found" 404
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Test mercure</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="GET">
|
||||
<input type="text" name="eventSource" value="" />
|
||||
|
||||
<button type="submit" name="submit" value="Submit">Submit</button>
|
||||
</form>
|
||||
<script>
|
||||
{% if app.request.query.has('eventSource') %}
|
||||
const eventSource = new EventSource("{{ mercure(app.request.query.get('eventSource'))|escape('js') }}");
|
||||
eventSource.onmessage = event => {
|
||||
// Will be called every time an update is published by the server
|
||||
console.log(JSON.parse(event.data));
|
||||
}
|
||||
{% endif %}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user