Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
51f0cc2b
Commit
51f0cc2b
authored
11 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
Embed doc synced
parent
25392700
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/Embed.md
+7
-11
7 additions, 11 deletions
docs/Embed.md
with
7 additions
and
11 deletions
docs/Embed.md
+
7
−
11
View file @
51f0cc2b
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
Embedding Mongoose is done in two steps:
Embedding Mongoose is done in two steps:
1.
Download and copy two files:
1.
Copy
[
mongoose.c
](
https://raw.github.com/cesanta/mongoose/master/mongoose.c
)
and
[
mongoose.c
](
https://raw.github.com/cesanta/mongoose/master/mongoose.c
)
and
[
mongoose.h
](
https://raw.github.com/cesanta/mongoose/master/mongoose.h
)
[
mongoose.h
](
https://raw.github.com/cesanta/mongoose/master/mongoose.h
)
to your application's source tree and include the
se two files
in the build.
to your application's source tree and include the
m
in the build.
2.
Somewhere in the application code, call
`mg_create_server()`
to create
2.
Somewhere in the application code, call
`mg_create_server()`
to create
a server, configure it with
`mg_set_option()`
and loop with
a server, configure it with
`mg_set_option()`
and loop with
`mg_poll_server()`
until done. Call
`mg_destroy_server()`
to cleanup.
`mg_poll_server()`
until done. Call
`mg_destroy_server()`
to cleanup.
...
@@ -51,8 +51,8 @@ http://127.0.0.1:8080/hello will say hello, and here's the code:
...
@@ -51,8 +51,8 @@ http://127.0.0.1:8080/hello will say hello, and here's the code:
#include "mongoose.h"
#include "mongoose.h"
static int handle_hello(struct mg_connection *conn) {
static int handle_hello(struct mg_connection *conn) {
static const char *reply = "
HTTP/1.0 200 OK\r\n\r\n
Hello world!\n";
static const char *reply = "Hello world!\n";
mg_write(conn, reply, strlen(reply));
mg_write
_data
(conn, reply, strlen(reply));
return 1;
return 1;
}
}
...
@@ -66,11 +66,6 @@ http://127.0.0.1:8080/hello will say hello, and here's the code:
...
@@ -66,11 +66,6 @@ http://127.0.0.1:8080/hello will say hello, and here's the code:
return 0;
return 0;
}
}
Note that URI handler must output valid HTTP response, which includes
the reply line with status code
`HTTP/1.0 200 OK`
, HTTP headers which are
empty in our example, and message body
`Hello world!\n`
. Note that reply
line is ended with
`\r\n`
, and HTTP headers are also ended with
`\r\n`
.
Below is the list of compilation flags that enable or disable certain
Below is the list of compilation flags that enable or disable certain
features. By default, some features are enabled, and could be disabled
features. By default, some features are enabled, and could be disabled
by setting appropriate
`NO_*`
flag. Features that are disabled by default
by setting appropriate
`NO_*`
flag. Features that are disabled by default
...
@@ -95,5 +90,6 @@ a couple of kilobytes to the executable size, and also has some runtime penalty.
...
@@ -95,5 +90,6 @@ a couple of kilobytes to the executable size, and also has some runtime penalty.
Mongoose source code contains a well-commented example code, listed below:
Mongoose source code contains a well-commented example code, listed below:
*
[
hello.c
](
https://github.com/cesanta/mongoose/blob/master/examples/hello.c
)
*
[
hello.c
](
https://github.com/cesanta/mongoose/blob/master/examples/hello.c
)
shows how to handle form input, file upload, websocket communication, get
is a minimalisting hello world example
cookie values.
*
[
post.c
](
https://github.com/cesanta/mongoose/blob/master/examples/post.c
)
shows how to handle form input
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment