HTTP
HTTP Read-only service support like Nginx and Caddy.
Capabilities
This service can be used to:
- stat
- read
-
write -
create_dir -
delete -
copy -
rename -
list -
presign - blocking
Notes
Only read
and stat
are supported. We can use this service to visit any
HTTP Server like nginx, caddy.
Configuration
endpoint
: set the endpoint for httproot
: Set the work directory for backend
You can refer to [HttpBuilder
]'s docs for more information
Example
Via Builder
use anyhow::Result;
use opendal::services::Http;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
// create http backend builder
let mut builder = Http::default();
builder.endpoint("127.0.0.1");
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
Via Config
- Rust
- Node.js
- Python
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("endpoint".to_string(), "127.0.0.1".to_string());
let op: Operator = Operator::via_map(Scheme::Http, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("http", {
endpoint: "127.0.0.1",
});
}
import opendal
op = opendal.Operator("http",
endpoint="127.0.0.1",
)