Skip to content
Snippets Groups Projects
Select Git revision
  • e53cfef013d2cb973b8a90587f611f87278ec438
  • without_tipselection default
  • develop protected
  • fix/grafana-local-dashboard
  • wasp
  • fix/dashboard-explorer-freeze
  • master
  • feat/timerqueue
  • test/sync_debug_and_650
  • feat/sync_revamp_inv
  • wip/sync
  • tool/db-recovery
  • portcheck/fix
  • fix/synchronization
  • feat/new-dashboard-analysis
  • feat/refactored-analysis-dashboard
  • feat/new-analysis-dashboard
  • test/demo-prometheus-fpc
  • prometheus_metrics
  • wip/analysis-server
  • merge/fpc-test-value-transfer
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
28 results

plugin.go

Blame
  • user avatar
    Luca Moser authored
    e53cfef0
    History
    plugin.go 766 B
    package httpserver
    
    import (
    	"net/http"
    	"time"
    
    	"github.com/iotaledger/hive.go/daemon"
    	"github.com/iotaledger/hive.go/node"
    	"golang.org/x/net/context"
    	"golang.org/x/net/websocket"
    )
    
    var (
    	httpServer *http.Server
    	router     *http.ServeMux
    )
    
    func Configure(plugin *node.Plugin) {
    	router = http.NewServeMux()
    	httpServer = &http.Server{Addr: ":80", Handler: router}
    
    	router.Handle("/datastream", websocket.Handler(dataStream))
    	router.HandleFunc("/", index)
    }
    
    func Run(plugin *node.Plugin) {
    	daemon.BackgroundWorker("Analysis HTTP Server", func(shutdownSignal <-chan struct{}) {
    		go httpServer.ListenAndServe()
    		<-shutdownSignal
    		ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second)
    		defer cancel()
    		httpServer.Shutdown(ctx)
    	})
    }