platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
35
selective-vpn-api/app/traffic_appmarks_handlers_post.go
Normal file
35
selective-vpn-api/app/traffic_appmarks_handlers_post.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func handleTrafficAppMarksPost(w http.ResponseWriter, r *http.Request) {
|
||||
in, badReqMessage := decodeTrafficAppMarksPostInput(r)
|
||||
if badReqMessage != "" {
|
||||
http.Error(w, badReqMessage, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if err := ensureAppMarksNft(); err != nil {
|
||||
writeJSON(w, http.StatusOK, TrafficAppMarksResponse{
|
||||
OK: false,
|
||||
Op: string(in.Op),
|
||||
Target: in.Target,
|
||||
Cgroup: in.Cgroup,
|
||||
Message: "nft init failed: " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
switch in.Op {
|
||||
case TrafficAppMarksAdd:
|
||||
writeJSON(w, http.StatusOK, executeTrafficAppMarksAdd(in))
|
||||
case TrafficAppMarksDel:
|
||||
writeJSON(w, http.StatusOK, executeTrafficAppMarksDelete(in))
|
||||
case TrafficAppMarksClear:
|
||||
writeJSON(w, http.StatusOK, executeTrafficAppMarksClear(in))
|
||||
default:
|
||||
http.Error(w, "unknown op", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user