Last active
November 5, 2019 15:54
-
-
Save wjiec/4f76bb61e29d327fead958cde0f6f1b0 to your computer and use it in GitHub Desktop.
微信直接打开默认浏览器
This file contains hidden or 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
| package main | |
| import ( | |
| "log" | |
| "net/http" | |
| "strings" | |
| ) | |
| func main() { | |
| http.HandleFunc("/", func(w http.ResponseWriter, request *http.Request) { | |
| userAgent := request.Header.Get("user-agent") | |
| if strings.Contains(userAgent, "MicroMessenger") && strings.Contains(userAgent, "Android") { | |
| w.Header().Add("Content-Disposition", "attachment; filename=1.apk") | |
| w.Header().Add("Content-Type", "text/plain; charset=utf-8") | |
| w.WriteHeader(http.StatusPartialContent) | |
| return | |
| } | |
| _, _ = w.Write([]byte("hello")) | |
| }) | |
| log.Fatal(http.ListenAndServe(":8898", nil)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment