Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var APIClient = `` /* 1440-byte string literal not displayed */
APIClient ...
View Source
var APIGo = `package api
import "context"
//go:generate {{ .Generator }} -type api -name {{ .Name }} -path {{ .Path }}
// StatusRequest ...
type StatusRequest struct {
}
// StatusResponse ...
type StatusResponse struct {
Text string ` + "`json:\"text\"`" + `
}
// StatusService ...
type StatusService func(ctx context.Context, req *StatusRequest) (res *StatusResponse, err error)`
APIGo ...
View Source
var APIHttp = `` /* 191-byte string literal not displayed */
APIHttp ...
View Source
var AssertGo = `` /* 421-byte string literal not displayed */
AssertGo ...
View Source
var Handlers2Go = `` /* 1684-byte string literal not displayed */
Handlers2Go ...
View Source
var HandlersGo = `` /* 1621-byte string literal not displayed */
HandlersGo ...
View Source
var MainGo4App = `` /* 381-byte string literal not displayed */
MainGo4App ...
View Source
var MainGo4Bin = `` /* 405-byte string literal not displayed */
MainGo4Bin ...
View Source
var Makefile = `` /* 332-byte string literal not displayed */
Makefile ...
View Source
var MiddlewareGo = `` /* 760-byte string literal not displayed */
MiddlewareGo ...
View Source
var Routes2Go = `` /* 517-byte string literal not displayed */
Routes2Go ...
View Source
var RoutesGo = `` /* 457-byte string literal not displayed */
RoutesGo ...
View Source
var Server2Go = `// Code generated by {{ .Generator }} {{ .Version }} ({{ .Build }}); DO NOT EDIT
package server
import (
"log"
"net/http"
"os"
"sync"
"{{ .Path }}/pkg/api"
)
type metrics struct {
ErrorCount map[string]int ` + "`json:\"error_count\"`" + `
RequestCount map[string]int ` + "`json:\"request_count\"`" + `
ResponseTimeMs map[string]int ` + "`json:\"response_time_ms\"`" + `
mutex sync.Mutex
}
// Server ...
type Server struct {
logger *log.Logger
metrics *metrics
router *http.ServeMux
{{ range $i, $name := .Services }}{{ lc $name }}Service api.{{ $name }}Service
{{ end }}
}
// ServeHTTP ...
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.router.ServeHTTP(w, r)
}
{{ range $i, $name := .Services }}
// With{{ $name }}Service ...
func (s *Server) With{{ $name }}Service(service api.{{ $name }}Service) {
s.{{ lc $name }}Service = service
}
{{ end }}
// NewServer ...
func NewServer() *Server {
srv := &Server{
logger: log.New(os.Stdout, "", log.LstdFlags),
metrics: &metrics{
ErrorCount: make(map[string]int),
RequestCount: make(map[string]int),
ResponseTimeMs: make(map[string]int),
},
router: http.NewServeMux(),
}
srv.routes()
return srv
}
func (s *Server) increaseErrorCount(r *http.Request) {
s.metrics.mutex.Lock()
s.metrics.ErrorCount[r.RequestURI]++
s.metrics.mutex.Unlock()
}`
Server2Go ...
View Source
var ServerGo = `// Code generated by {{ .Generator }} {{ .Version }} ({{ .Build }}); DO NOT EDIT
package server
import (
"log"
"net/http"
"os"
"sync"
"{{ .Path }}/pkg/api"
)
type metrics struct {
ErrorCount map[string]int ` + "`json:\"error_count\"`" + `
RequestCount map[string]int ` + "`json:\"request_count\"`" + `
ResponseTimeMs map[string]int ` + "`json:\"response_time_ms\"`" + `
mutex sync.Mutex
}
// Server ...
type Server struct {
logger *log.Logger
metrics *metrics
router *http.ServeMux
statusService api.StatusService
}
// ServeHTTP ...
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.router.ServeHTTP(w, r)
}
// WithStatusService ...
func (s *Server) WithStatusService(service api.StatusService) {
s.statusService = service
}
// NewServer ...
func NewServer() *Server {
srv := &Server{
logger: log.New(os.Stdout, "", log.LstdFlags),
metrics: &metrics{
ErrorCount: make(map[string]int),
RequestCount: make(map[string]int),
ResponseTimeMs: make(map[string]int),
},
router: http.NewServeMux(),
}
srv.routes()
return srv
}
func (s *Server) increaseErrorCount(r *http.Request) {
s.metrics.mutex.Lock()
s.metrics.ErrorCount[r.RequestURI]++
s.metrics.mutex.Unlock()
}
`
ServerGo ...
View Source
var ServiceGo = `` /* 329-byte string literal not displayed */
ServiceGo ...
View Source
var ServiceTestGo = `` /* 310-byte string literal not displayed */
ServiceTestGo ...
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.