Exemple #1
0
func (this *HttpServer) URLHandler(w http.ResponseWriter, r *http.Request) {
	params := r.URL.Query()
	url := params.Get("url")
	document := new(models.DocumentEntity)
	document.Url = url

	ch := make(chan *models.DocumentEntity)
	defer close(ch)
	go this.context.Engine.NLP.Workflow(document, ch)
	output := <-ch

	js := output.ToJSON()
	b, err := json.Marshal(js)

	if err != nil {
		w.Write([]byte(fmt.Sprintf("%s\n", err.Error())))
	} else {
		w.Write([]byte(fmt.Sprintf("%s\n", string(b))))
	}
}