remove gin use net/http
This commit is contained in:
		
							
								
								
									
										25
									
								
								test/test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								test/test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"flag"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	s := flag.String("s", "yumc.pw", "Source Server Host(Default: yumc.pw)")
 | 
			
		||||
	t := flag.String("t", "https://git.yumc.pw", "Target Server Host(Default: https://git.yumc.pw)")
 | 
			
		||||
	p := flag.String("p", "git", "Target Server Type(Default: git)")
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		path := r.RequestURI
 | 
			
		||||
		if strings.Contains(path, "?") {
 | 
			
		||||
			path = strings.Split(path, "?")[0]
 | 
			
		||||
		}
 | 
			
		||||
		w.Write([]byte(
 | 
			
		||||
			fmt.Sprintf("<meta name=\"go-import\" content=\"%s%s %s %s%s\">",
 | 
			
		||||
				*s, path, *p, *t, path)))
 | 
			
		||||
	})
 | 
			
		||||
	http.ListenAndServe(":8080", nil)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user