commit - 2625e3b992c23567e34d9dc1be8c364cd637a2ae
commit + 7e68a5d0527a3766aaa202e4bc72dcf36c01436b
blob - 543c1daefddb255476d8b3868e27583d42788de9
blob + 91af43266592c3382ac6072c36751037b6cbecb0
--- Makefile
+++ Makefile
LIB = $(BUILD)/libhttp.rlib
TEST = $(BUILD)/http-test
+EXAMPLE_SRCS = $(wildcard examples/*.rs)
+EXAMPLES = $(EXAMPLE_SRCS:examples/%.rs=$(BUILD)/ex-%)
+
CLIPPY ?= $(shell rustup which clippy-driver 2>/dev/null)
RUSTFMT ?= $(shell rustup which rustfmt 2>/dev/null)
RUSTDOC ?= $(shell rustup which rustdoc 2>/dev/null || which rustdoc)
DOC = $(BUILD)/doc/http/index.html
-.PHONY: all clean test fmt-check clippy ci doc
+.PHONY: all clean test fmt-check clippy ci doc examples
all: $(LIB)
doc: $(DOC)
+$(BUILD)/ex-%: examples/%.rs $(LIB)
+ mkdir -p $(BUILD)
+ HTTP_VERSION=$(VERSION) $(RUSTC) --edition 2024 \
+ --crate-name $* --extern http=$(LIB) -L $(BUILD) \
+ $(RUSTFLAGS) -o $@ $<
+
+examples: $(EXAMPLES)
+
clean:
rm -rf $(BUILD)
blob - 1eea2e11450dfca287e834eb2402ceec265f3da1
blob + a8a2b033e1f69886ce6871a74a6bcc2ddf8d34af
--- http.rs
+++ http.rs
//! Minimal HTTP/1.0 and HTTP/1.1 library.
//!
//! Conforms to RFC 1945 (HTTP/1.0) and RFC 2616 (HTTP/1.1).
+
+/// Library version, injected at build time from `HTTP_VERSION`.
+pub const VERSION: &str = env!("HTTP_VERSION");
blob - /dev/null
blob + 4892e65bd93d77dad9563a42ab33071219c1415f (mode 644)
--- /dev/null
+++ examples/hello.rs
+// vim: set tw=79 cc=80 ts=4 sw=4 sts=4 et :
+//
+// Copyright (c) 2026 Murilo Ijanc' <murilo@ijanc.org>
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+//
+
+//! Minimal example that links against the http library.
+
+fn main() {
+ println!("http v{}", http::VERSION);
+}