aboutsummaryrefslogtreecommitdiff
path: root/idp/idpmiddleware/_example/test.go
blob: b63009ec160460073edcae219e6fa7f25bc7fc9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//+build ignore

package main

import (
	"flag"
	"log"
	"net/http"

	"within.website/x/idp/idpmiddleware"
	"within.website/x/internal"
	"within.website/ln/ex"
)

var (
	port    = flag.String("port", "6060", "TCP port")
	server  = flag.String("server", "https://idp.christine.website", "idp server")
	me      = flag.String("me", "https://christine.website/", "self-identity")
	selfURL = flag.String("self-url", "http://127.0.0.1:6060/", "redirect URL for the self.")
)

func main() {
	internal.HandleStartup()
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.Error(w, "success!", http.StatusOK)
	})

	log.Fatal(http.ListenAndServe(":"+*port, ex.HTTPLog(idpmiddleware.Protect(*server, *me, *selfURL)(http.DefaultServeMux))))
}