-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options to set BlockProfileRate and MutexProfileFraction
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
- Loading branch information
Jakub Sztandera
committed
Oct 2, 2020
1 parent
efc1b24
commit 6b5f8a6
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
"strconv" | ||
) | ||
|
||
func handleFractionOpt(name string, setter func(int)) http.HandlerFunc { | ||
return func(rw http.ResponseWriter, r *http.Request) { | ||
if r.Method != http.MethodPost { | ||
http.Error(rw, "only POST allowed", http.StatusMethodNotAllowed) | ||
return | ||
} | ||
if err := r.ParseForm(); err != nil { | ||
http.Error(rw, err.Error(), http.StatusBadRequest) | ||
return | ||
} | ||
|
||
asfr := r.Form.Get("x") | ||
if len(asfr) == 0 { | ||
http.Error(rw, "parameter 'x' must be set", http.StatusBadRequest) | ||
return | ||
} | ||
|
||
fr, err := strconv.Atoi(asfr) | ||
if err != nil { | ||
http.Error(rw, err.Error(), http.StatusBadRequest) | ||
return | ||
} | ||
log.Infof("setting %s to %d", name, fr) | ||
setter(fr) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters