Documentation
¶
Overview ¶
Standard library interop.
Okapi speaks net/http: existing handlers and middleware drop in unchanged, so an existing application can be adopted one route at a time. This example registers the same server three ways — standard middleware, standard handlers, and native Okapi handlers — and shows them sharing one middleware chain.
Run it, then try:
curl localhost:8080/greeting curl localhost:8080/users/42 # r.PathValue inside a std handler curl localhost:8080/api/legacy # std handler behind group middleware curl localhost:8080/assets/style.css # http.FileServer on a catch-all curl localhost:8080/users # native handler, for contrast curl -i localhost:8080/greeting # note X-Powered-By from std middleware
Click to show internal directories.
Click to hide internal directories.