https://github.com/acatton/memoryhttpd
HTTP Server with its resources stored in memory
https://github.com/acatton/memoryhttpd
Last synced: 11 months ago
JSON representation
HTTP Server with its resources stored in memory
- Host: GitHub
- URL: https://github.com/acatton/memoryhttpd
- Owner: acatton
- License: isc
- Created: 2023-03-10T15:31:05.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-10T16:16:58.000Z (about 3 years ago)
- Last Synced: 2025-04-06T04:45:47.957Z (about 1 year ago)
- Language: Rust
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
memoryhttpd
===========

memoryhttpd is an in-memory HTTP server. Resources can be added by using PUT.
It supports multiple hosts.
For example:
```
$ curl -v http://localhost:3000/foo/bar/ -H Host:example.com -X PUT -d 'hello world'
> PUT /foo/bar/ HTTP/1.1
> Host:example.com
> Content-Length: 11
>
< HTTP/1.1 200 OK
< x-memoryhttpd-action: set
< content-length: 11
< date: Thu, 09 Mar 2023 20:32:07 GMT
<
hello world
$ curl -v http://localhost:3000/foo/bar/ -H Host:example.com
> GET /foo/bar/ HTTP/1.1
> Host:example.com
>
< HTTP/1.1 200 OK
< content-length: 11
< date: Thu, 09 Mar 2023 20:33:22 GMT
<
hello world
$ curl -v http://localhost:3000/foo/bar/ -H Host:example.net
> GET /foo/bar/ HTTP/1.1
> Host:example.net
> User-Agent: curl/7.85.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< content-length: 0
< date: Thu, 09 Mar 2023 20:33:28 GMT
<
```
Commands
--------
Set a value:
```
PUT /full/path HTTP/1.1
Host: hostname
Content-Length: 5
value
```
Get a value:
```
GET /full/path HTTP/1.1
Host: hostname
```
Delete a value:
```
DELETE /full/path HTTP/1.1
Host: hostname
```
Set with an expiration (in milliseconds):
```
PUT /full/path HTTP/1.1
Host: hostname
X-Expire-ms: 30000
Content-Length: 21
value expiring in 30s
```
Use cases
---------
### acme challenges
memoryhttpd can be used to store temporary tokens. For example using it as a
backend for `/.well-known/acme-challenges/` for a reverse proxy.
Mirrors
-------
This repository is mirrored on:
* https://codeberg.org/acatton/memoryhttpd
* https://github.com/acatton/memoryhttpd