f-21: code: ajout d'un system de worker
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
dc701886eb
commit
2fbde24e89
8 changed files with 87 additions and 14 deletions
|
|
@ -5,15 +5,20 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
func SubnetsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) SubnetsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode([]interface{}{})
|
||||
case http.MethodPost:
|
||||
s.queue.Submit(func() {
|
||||
createSubnet()
|
||||
})
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
default:
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
func createSubnet() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue