Apache module
Go Server Pages integrates with the Apache Web server in the form of an Apache module. The source code for the Apache module lies in the module
directory. The module performs a number of tasks:
-
processing Go Server Pages-related directives appearing in the configuration file,
-
compiling pages to Go plugins using
gosp2go
, -
running Go plugins using
gosp-server
, -
sending client request data to the Go plugin, and
-
sending the output of the Go plugin back to the client.
The following flowchart illustrates the Go Server Pages module’s control flow when processing a request from a client:
The left side of the flowchart corresponds to the common case of an up-to-date version of the Go Server Pages plugin already being running. The right side of the flowchart corresponds to the plugin not existing, in which case it is compiled using gosp2go
and launched using gosp-server
; or outdated, in which case it is stopped, recompiled, and relaunched. While not shown in the figure, the actions on the right side of the figure are protected by a mutex to ensure that concurrent accesses to an outdated or nonexistent plugin do not trigger multiple compilations or launches of the same plugin.
If the Abort state in the flowchart is reached, the Go Server Pages Apache module returns to the client an HTTP Internal Server Error (status code 500).