Skip to content

Instantly share code, notes, and snippets.

@pspeter3
Last active February 19, 2016 18:28
Show Gist options
  • Save pspeter3/cae319e39a74f7c0c14d to your computer and use it in GitHub Desktop.
Save pspeter3/cae319e39a74f7c0c14d to your computer and use it in GitHub Desktop.
IFTTT Maker Channel Asana Proxy
package main
import (
"flag"
"log"
"net/http"
"net/url"
)
type handler struct{}
func (h handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
token := req.URL.Path[1:]
redirectURL, _ := url.Parse("https://app.asana.com/api/1.0/tasks")
out := new(http.Request)
*out = *req
out.Method = "POST"
out.URL = redirectURL
out.Header.Set("Authorization", "Bearer "+token)
_, err := http.DefaultTransport.RoundTrip(out)
if err != nil {
log.Println(err)
rw.WriteHeader(http.StatusInternalServerError)
}
}
func main() {
addr := flag.String("addr", ":3000", "Address to bind")
flag.Parse()
log.Fatal(http.ListenAndServe(*addr, handler{}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment