/* Copyright 2006 Paul Querna * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "proton.h" #include "cgi.h" const char *env_vars[] = { "AUTH_TYPE", "DOCUMENT_ROOT", "CONTENT_LENGTH", "CONTENT_TYPE", "GATEWAY_INTERFACE", "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING", "HTTP_ACCEPT_LANGUAGE", "HTTP_CONNECTION", "HTTP_COOKIE", "HTTP_HOST", "HTTP_KEEP_ALIVE", "HTTP_REFERRER", "HTTP_USER_AGENT", "PATH", "PATH_INFO", "QUERY_STRING", "REMOTE_ADDR", "REMOTE_HOST", "REQUEST_METHOD", "REQUEST_URI", NULL }; static int handle_hello(pwt_ctxt_t *ctxt, void *baton) { etl_variable_t *env = etl_variable_make_hash(); unsigned int i = 0; for (i=0; env_vars[i]; i++) { char *data = getenv(env_vars[i]); if (data) { etl_variable_hash_set(env, env_vars[i], etl_variable_make_str(data)); } } etl_hash_set(pwt_etl_getenv(ctxt), "env", env); return pwt_render_template(ctxt, "helloworld.etl"); } static void reg_handlers(pwt_module_t *pmod, pwt_ctxt_t *pwt) { pwt_register_handler_default(pmod, pwt, handle_hello); } PWT_MODULE_DECL(helloworld, reg_handlers);