File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,28 @@ requests.
177
177
if $self->req->headers->header('X-Forwarded-Protocol') eq 'https';
178
178
});
179
179
180
+ =head2 Embedding
181
+
182
+ You can also use the builtin web server to embed L<Mojolicious> applications
183
+ into alien environments like foreign event loops.
184
+
185
+ use Mojolicious::Lite;
186
+ use Mojo::Server::Daemon;
187
+
188
+ # Normal action
189
+ get '/' => sub {
190
+ my $self = shift;
191
+ $self->render(text => 'Hello World!');
192
+ };
193
+
194
+ # Connect application with custom daemon
195
+ my $daemon =
196
+ Mojo::Server::Daemon->new(app => app, listen => ['http://*:8080']);
197
+ $daemon->prepare_ioloop;
198
+
199
+ # Call "one_tick" repeatedly from the alien environment
200
+ $daemon->ioloop->one_tick while 1;
201
+
180
202
=head1 USER AGENT
181
203
182
204
When we say L<Mojolicious> is a web framework we actually mean it.
You can’t perform that action at this time.
0 commit comments