Skip to content

Commit

Permalink
Merge pull request #5 from TIT8/patch
Browse files Browse the repository at this point in the history
Patch
  • Loading branch information
TIT8 authored Aug 27, 2023
2 parents 632ee28 + adb511f commit f30e909
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions form-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ type Request struct {
}

func getUrl() string {

return fmt.Sprintf("https://api.telegram.org/bot%s", Token)

}

func SendMessage(text string) (bool, error) {

var err error
var response *http.Response

Expand All @@ -58,18 +61,22 @@ func SendMessage(text string) (bool, error) {
defer response.Body.Close()

return true, nil

}

func handler_get(w http.ResponseWriter, r *http.Request) {

if r.Method != "GET" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}

fmt.Fprintf(w, "Ciao %s\n", r.Host)

}

func handler_post(w http.ResponseWriter, r *http.Request) {

if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
Expand Down Expand Up @@ -157,10 +164,14 @@ func handler_post(w http.ResponseWriter, r *http.Request) {

w.Header().Set("Content-Type", "application/json")
w.Write(res)

}

func main() {

http.HandleFunc("/", handler_get)
http.HandleFunc("/post", handler_post)

log.Fatal(http.ListenAndServe(":8080", nil))

}

0 comments on commit f30e909

Please sign in to comment.