80-column limit. I print code sometimes.
[fbfp.git] / main.go
blob8b2d6bcfea4bb2f1023dbbf2b4b5bbe96f994b35
1 package main
3 import (
4 "log"
5 "net"
6 "net/http"
7 "net/http/fcgi"
10 func handle_index(w http.ResponseWriter, req *http.Request) {
11 openid_authorization_url := generate_authorization_url()
13 http.Redirect(w, req, openid_authorization_url, 303)
16 func main() {
17 fbfp_get_config("fbfp.scfg")
19 log.Printf("Fetching OpenID Connect configuration\n")
20 get_openid_config(config.Openid.Endpoint)
22 log.Printf("Registering handlers\n")
23 http.HandleFunc("/", handle_index)
24 http.HandleFunc(config.Openid.Redirect, handle_oidc)
26 log.Printf(
27 "Establishing listener for net %s, addr %s\n",
28 config.Net,
29 config.Addr,
32 l, err := net.Listen(config.Net, config.Addr)
33 e(err)
35 if config.Proto == "http" {
36 log.Printf("Serving http\n")
37 err = http.Serve(l, nil)
38 } else if config.Proto == "fcgi" {
39 log.Printf("Serving fcgi\n")
40 err = fcgi.Serve(l, nil)
42 e(err)