-
Notifications
You must be signed in to change notification settings - Fork 56
/
examples_test.go
53 lines (47 loc) · 1.25 KB
/
examples_test.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package scim
import (
logger "log"
"net/http"
)
func ExampleNewServer() {
args := &ServerArgs{
ServiceProviderConfig: &ServiceProviderConfig{},
ResourceTypes: []ResourceType{},
}
server, err := NewServer(args)
if err != nil {
logger.Fatal(err)
}
logger.Fatal(http.ListenAndServe(":7643", server))
}
func ExampleNewServer_basePath() {
args := &ServerArgs{
ServiceProviderConfig: &ServiceProviderConfig{},
ResourceTypes: []ResourceType{},
}
server, err := NewServer(args)
if err != nil {
logger.Fatal(err)
}
// You can host the SCIM server on a custom path, make sure to strip the prefix, so only `/v2/` is left.
http.Handle("/scim/", http.StripPrefix("/scim", server))
logger.Fatal(http.ListenAndServe(":7643", nil))
}
func ExampleNewServer_logger() {
loggingMiddleware := func(next http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
logger.Println(r.Method, r.URL.Path)
next.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
}
args := &ServerArgs{
ServiceProviderConfig: &ServiceProviderConfig{},
ResourceTypes: []ResourceType{},
}
server, err := NewServer(args)
if err != nil {
logger.Fatal(err)
}
logger.Fatal(http.ListenAndServe(":7643", loggingMiddleware(server)))
}