Skip to content

Commit

Permalink
Add verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nodauf committed Jan 12, 2022
1 parent ad25db4 commit ecb3052
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ var SearchAndReplaceMap = make(map[string]string)
// TLSConfig contains the configuration for the webserver
var TLSConfig tls.Config

// Verbose enable a verbose output
var Verbose bool

// cert contains certificate and private key
var cert *tls.Certificate

Expand Down Expand Up @@ -105,7 +108,7 @@ var webCmd = &cobra.Command{
} else if TLS && (!utils.FileExists(tlsCertificate) || !utils.FileExists(tlsKey)) { //if TLS enable check if the certificate and key files not exist
return errors.New("Certificate file " + tlsCertificate + " or key file " + tlsKey + " not found")

} else if TLS && utils.FileExists(tlsCertificate) && utils.FileExists(tlsKey){
} else if TLS && utils.FileExists(tlsCertificate) && utils.FileExists(tlsKey) {
cer, err := tls.LoadX509KeyPair(tlsCertificate, tlsKey)
if err != nil {
return errors.New(err.Error())
Expand Down Expand Up @@ -189,4 +192,6 @@ func init() {

webCmd.Flags().BoolVarP(&DisableListing, "disableListing", "d", false, "Disable directory listing")

webCmd.Flags().BoolVarP(&Verbose, "verbose", "v", false, "Verbose output")

}
1 change: 0 additions & 1 deletion src/controllers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func UploadFile(w http.ResponseWriter, r *http.Request) {
r.URL.Path = strings.Replace(r.URL.Path, "/private/", "", 1)
filepath = path.Join((cmd.PrivateFolder), path.Clean(r.URL.Path))
}
fmt.Println(r.URL.Path)
// Maximum upload of 1000 MB files
r.ParseMultipartForm(10000000 << 20)
// If the variable files exists
Expand Down
13 changes: 13 additions & 0 deletions src/routers/router.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package routers

import (
"Swego/src/cmd"
"Swego/src/controllers"
"fmt"
"io/ioutil"
"net/http"
)

Expand All @@ -27,6 +29,17 @@ func Router(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "ParseForm() err: %v", err)
return
}
if cmd.Verbose {
data, err := ioutil.ReadAll(req.Body)
if err == nil && len(data) > 0 {
fmt.Println(string(data))
}
req.ParseForm()
for key, value := range req.Form {
fmt.Printf("%s => %s \n", key, value)
}

}
controllers.UploadFile(w, req)

default:
Expand Down

0 comments on commit ecb3052

Please sign in to comment.