Initial commit
This commit is contained in:
34
serve.go
Normal file
34
serve.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func index(w http.ResponseWriter, r *http.Request) {
|
||||
formatRequest(r)
|
||||
fmt.Fprintf(w, "Hello go!\n")
|
||||
}
|
||||
|
||||
func formatRequest(r *http.Request) {
|
||||
|
||||
var opt Option
|
||||
err := json.NewDecoder(r.Body).Decode(&opt)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %s\n", err)
|
||||
}
|
||||
|
||||
fmt.Println("Option type:", opt.optType)
|
||||
fmt.Println("Strike:", opt.strike)
|
||||
fmt.Println("Expiry date:", opt.expiryDate.Format("2006-01-02"))
|
||||
|
||||
for k, v := range r.Header {
|
||||
fmt.Printf("%v: %v\n", k, v)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", index)
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
Reference in New Issue
Block a user