templates

package
v0.0.47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIClient = `` /* 1537-byte string literal not displayed */

APIClient ...

View Source
var APIGo = `package api

import "context"

//go:generate {{ .Generator }} -type api -name {{ .Name }} -path {{ .Path }}
//go:generate {{ .Generator }} -type bundle -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 = `` /* 271-byte string literal not displayed */

APIHttp ...

View Source
var AssertGo = `` /* 421-byte string literal not displayed */

AssertGo ...

View Source
var BundleAppJs = `` /* 999-byte string literal not displayed */

BundleAppJs ...

View Source
var BundleAppScss = `
@import "flat-mixins.scss";
@import "flat-reset.scss";`

BundleAppScss ...

View Source
var BundleFlatElementJs = `` /* 1247-byte string literal not displayed */

BundleFlatElementJs ...

View Source
var BundleFlatMixinsScss = `` /* 1332-byte string literal not displayed */

BundleFlatMixinsScss ...

View Source
var BundleFlatResetScss = `` /* 267-byte string literal not displayed */

BundleFlatResetScss ...

View Source
var BundleIndexHTML = `` /* 579-byte string literal not displayed */

BundleIndexHTML ...

View Source
var BusGo = `` /* 897-byte string literal not displayed */

BusGo ...

View Source
var BusTest = `` /* 634-byte string literal not displayed */

BusTest ...

View Source
var Gitkeep = ``

Gitkeep ...

View Source
var Handlers2Go = `` /* 1815-byte string literal not displayed */

Handlers2Go ...

View Source
var HandlersGo = `` /* 1736-byte string literal not displayed */

HandlersGo ...

View Source
var MainGo4App = `` /* 432-byte string literal not displayed */

MainGo4App ...

View Source
var MainGo4Bin = `` /* 405-byte string literal not displayed */

MainGo4Bin ...

View Source
var Makefile = `` /* 573-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"
	"{{ .Path }}/pkg/event"
)

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 {
	bus           *event.Bus
	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(bus *event.Bus) *Server {
	srv := &Server{
		bus:    bus,
		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"
	"{{ .Path }}/pkg/event"
)

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 {
	bus           *event.Bus
	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(bus *event.Bus) *Server {
	srv := &Server{
		bus:    bus,
		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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL