https://github.com/x-mod/httpserver
httpserver for grpc/pb
https://github.com/x-mod/httpserver
Last synced: 5 months ago
JSON representation
httpserver for grpc/pb
- Host: GitHub
- URL: https://github.com/x-mod/httpserver
- Owner: x-mod
- License: mit
- Created: 2019-08-21T14:46:10.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-04T10:27:42.000Z (over 2 years ago)
- Last Synced: 2024-02-04T11:51:25.217Z (over 2 years ago)
- Language: Go
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
httpserver
===
Another HTTP Server use handler with context & Response Render.
# Quick Start
````go
package main
import (
"context"
"log"
"net/http"
"github.com/x-mod/httpserver"
)
func main() {
srv := httpserver.NewServer(
httpserver.Address(":8080"),
)
srv.Route(
httpserver.Pattern("/hello"),
httpserver.Handler(http.HandlerFunc(Hello)),
)
log.Println("httpserver:", srv.Serve(context.TODO()))
}
func Hello(wr http.ResponseWriter, req *http.Request) {
wr.WriteHeader(http.StatusOK)
_, _ = wr.Write([]byte("I'm OK"))
}
````