Skip to content

JoseKling/HTTPServer.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTPServer.jl

This is a simple HTTP server for educational purposes only, to better understand how a server, or more specifically, a REST API server works.

The package allows users to set routes and start a server to listen for connections and handle requests. Here is an example.

using HTTPServer

sum_handler(dict) = sum(dict[:data])
greeting_handler(name) = "Hello there, $(name)!"

router = Router()
add_route!(router, "POST", "/sum", sum_handler)
add_route!(router, "POST", "/greeting", greeting_handler)
add_route!(router, "GET", "/", () -> "Available routes: $(router.routes))"

start_server(router; port=8000)

Notice that the payload is not validated. It will simply send whatever was in the body (provided the Content-Type is either application/json or text/plain) to the handlers.

About

A simple HTTP server for handling JSON or TEXT requests and returning JSON or TEXT responses.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages