Skip to content

AbrJA/Mongoose.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Mongoose.jl is a Julia package that provides a lightweight and efficient interface for building HTTP servers and web applications. It leverages the Mongoose C library to deliver fast, embeddable web server capabilities directly from Julia code. The package is designed for simplicity and ease of use. With Mongoose.jl, users can define routes, handle HTTP requests, and serve dynamic or static content with minimal setup.

Install

] add Mongoose

Example

Simple HTTP server

This example demonstrates how to use the Mongoose.jl package to create a basic HTTP server in Julia. The server registers a single route (/hello) that responds to GET requests with a JSON message.

  • Loading library
using Mongoose
  • JSON response

  • Request handler

function greet(conn; kwargs...)
    mg_json_reply(conn, 200, "{\"message\":\"Hello World from Julia!\"}")
end
  • Route registration
mg_register!("get", "/hello", greet)
  • Start server
mg_serve!()
  • Shoutdown server
mg_shutdown!()