-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhttp.go
35 lines (30 loc) · 783 Bytes
/
http.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
package gosddl
import (
"encoding/json"
"log"
"net/http"
"github.com/gorilla/mux"
)
func getInfo(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode("Hello")
}
func (app *ACLProcessor) decode(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
if params["sddl"] != "" {
sddl := params["sddl"]
err := app.findGroupIndex(sddl)
if err != nil {
log.Println("Wrong SDDL string")
}
json.NewEncoder(w).Encode(app.Rights)
app.Rights = permissions{}
return
}
}
// HTTPHandler start http serve
func (app *ACLProcessor) HTTPHandler(port string) {
router := mux.NewRouter()
router.HandleFunc("/sddl", getInfo).Methods("GET")
router.HandleFunc("/sddl/{sddl}", app.decode).Methods("GET")
log.Fatal(http.ListenAndServe(port, router))
}