Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
github.com/go-micro/plugins/v4/server/http
The HTTP Server is a go-micro.Server. It's a partial implementation which strips out codecs, transports, etc but enables you to create a HTTP Server that could potentially be used for REST based API services.
import (
"net/http"
"github.com/micro/go-micro/server"
httpServer "github.com/go-micro/plugins/v4/server/http"
)
func main() {
srv := httpServer.NewServer(
server.Name("helloworld"),
)
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`hello world`))
})
hd := srv.NewHandler(mux)
srv.Handle(hd)
srv.Start()
srv.Register()
}
Or as part of a service
import (
"net/http"
"go-micro.dev/v4"
"github.com/micro/go-micro/server"
httpServer "github.com/go-micro/plugins/v4/server/http"
)
func main() {
srv := httpServer.NewServer(
server.Name("helloworld"),
)
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`hello world`))
})
hd := srv.NewHandler(mux)
srv.Handle(hd)
service := micro.NewService(
micro.Server(srv),
)
service.Init()
service.Run()
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.