Skip to content

giucal/abserve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal HTTP server that serves a virtual resource directly from memory.

% echo '<p>Hello, world!</p>' | abserve /index.html &
[1] 56382
% curl http://localhost:8080/index.html
<p>Hello, world!</p>

Overview

The resource is read either once and for all from standard input or, with the --poll option, repeatedly from a FIFO:

% mkfifo resource.fifo
% abserve --poll resource.fifo &
[1] 56385
% echo A > resource.fifo
% curl http://localhost:8080
A

Writing to the FIFO causes abserve to update the resource:

% echo B > resource.fifo      # update
% curl http://localhost:8080
B
% curl http://localhost:8080  # the resource is cached
B

It's also possible to serve concrete resources from a given directory. The virtual resource takes precedence over anything else.

% ls
cat.jpg   dog.jpg   index.html
% cat index.html                            # index.html on disk
<img src="dog.jpg">
% echo '<img src="cat.jpg">' | abserve --directory . /index.html &
[1] 56388
% curl http://localhost:8080/index.html     # virtual index.html
<img src="cat.jpg">
% curl http://localhost:8080/cat.jpg | catimg

cat.jpg


Enough with cats.

For details, see the man page.

Installation

go install github.com/giucal/abserve@latest

About

Serve a file from memory.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published