Simple HTTP FileServer made for infimesh, but can be extended and applied for other services with simillar purposes.
Right now only FileSystem storage is supported.
Server understands two things:
- namespaces (folders)
- files (well, just files)
So these are routes:
GET /{ns} - returns stats (files and their props) in the requested namespace DELETE /{ns} - deletes namespace(and its files) GET /{ns}/{file} - returns file itself POST /{ns}/{file} - uploads file DELETE /{ns}/{file} - deletes file
See the Postman Collection to try it yourself.
Docker(compose) service example:
http-fs:
image: ghcr.io/infinimesh/http-fs:latest
restart: always
ports:
- "80:8000"
environment:
ADDR: :8000
REPO: repo:8000
STATIC_DIR: /static # you should probably map this to some real volume
UPLOAD_LIMIT: 10485760 # 10MB
LOG_LEVEL: -1 # -1 for debug, 0 for info, 1 for warning, 2 for error (defaults to info)
Namespaces are mapped to:
- infinimesh namespaces - middleware determines access to the folder basing on the user's permissions
- filesystem directory
These is the result of using InfinimeshMiddleware and FileSystem IOHandler
Middleware is a mux
middleware which adds Access
to context.
Access defined here. It's a simple structure which defined if requestor has Read and Write access to the namespace/file.
You can also see the SampleMiddleware to (maybe) get a better idea.
IOHandler is an interface which has few methods decribed here
Replace used middlewares and IOHandler with your own and compile.