Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
51f0cc2b
Commit
51f0cc2b
authored
Jan 04, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Embed doc synced
parent
25392700
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
Embed.md
docs/Embed.md
+7
-11
No files found.
docs/Embed.md
View file @
51f0cc2b
...
...
@@ -2,10 +2,10 @@
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.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
a server, configure it with
`mg_set_option()`
and loop with
`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:
#include "mongoose.h"
static int handle_hello(struct mg_connection *conn) {
static const char *reply = "H
TTP/1.0 200 OK\r\n\r\nH
ello world!\n";
mg_write(conn, reply, strlen(reply));
static const char *reply = "Hello world!\n";
mg_write
_data
(conn, reply, strlen(reply));
return 1;
}
...
...
@@ -66,11 +66,6 @@ http://127.0.0.1:8080/hello will say hello, and here's the code:
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
features. By default, some features are enabled, and could be disabled
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.
Mongoose source code contains a well-commented example code, listed below:
*
[
hello.c
](
https://github.com/cesanta/mongoose/blob/master/examples/hello.c
)
shows how to handle form input, file upload, websocket communication, get
cookie values.
is a minimalisting hello world example
*
[
post.c
](
https://github.com/cesanta/mongoose/blob/master/examples/post.c
)
shows how to handle form input
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment