Skip to content

Instantly share code, notes, and snippets.

@wjiec
Last active November 5, 2019 15:54
Show Gist options
  • Select an option

  • Save wjiec/4f76bb61e29d327fead958cde0f6f1b0 to your computer and use it in GitHub Desktop.

Select an option

Save wjiec/4f76bb61e29d327fead958cde0f6f1b0 to your computer and use it in GitHub Desktop.

Revisions

  1. wjiec revised this gist Nov 5, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion open_default_browser.go
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    package main

    import (
    "fmt"
    "log"
    "net/http"
    "strings"
  2. wjiec revised this gist Oct 16, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion open_default_browser.go
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,6 @@ import (
    func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, request *http.Request) {
    userAgent := request.Header.Get("user-agent")
    fmt.Println(userAgent)
    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")
  3. wjiec created this gist Oct 16, 2019.
    24 changes: 24 additions & 0 deletions open_default_browser.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    package main

    import (
    "fmt"
    "log"
    "net/http"
    "strings"
    )

    func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, request *http.Request) {
    userAgent := request.Header.Get("user-agent")
    fmt.Println(userAgent)
    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))
    }