E12022: program creates HTTP without 'with application of' linkage
What went wrong
The program creates an HTTP server instance but has no 'with application of' linkage. Without an application, the HTTP server has no way to discover which services to bind — service registration and route binding happen through the application block.
An HTTP is judged by the VALUE the program creates, never by the type of the variable that holds it: '-> server as Server: HTTP(props)', an HTTP returned by a function, and an HTTP passed straight to a function are all an HTTP the program creates.
Worked examples
The [EXAMPLE] section below shows a program that creates an HTTP server with no application linked, then the program linked 'with application of' one that registers a service. Holding the server through the Server trait changes nothing: 'server as Server: HTTP(props)' in a try is still an HTTP with no application.
Rationale
An HTTP server without an application has no services to serve. The 'with application of' linkage is what connects the service registry to the HTTP server at startup. Without it, the server would start but have an empty routing table.
EK9 requires this wiring to be explicit and complete at compile time.
How to fix it
Add 'with application of <AppName>' to the program declaration, where <AppName> is an application that registers the services to be served.
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E12022: program creates HTTP without 'with application of' linkage
#!ek9 defines module error.e12022.bad defines program HttpWithoutAppDemo() props <- NetworkProperties(9090) HTTP(props).serve()
Fixed: Link the program to an application with services
#!ek9 defines module error.e12022.good defines service HelloService for :/api open health() as GET for :/status <- response as HTTPResponse: () with trait of HTTPResponse override status() as pure <- rtn as Integer: 200 override content() <- rtn as Bytes: Bytes().withUtf8("ok") override contentType() as pure <- rtn as String: "text/plain" default operator ? defines application HelloApp register HelloService() defines program HttpWithAppDemo() with application of HelloApp props <- NetworkProperties(9090) HTTP(props).serve()