Skip to content

Add full example for kitgen  #639

@Raffo

Description

@Raffo

Hi, I was having a look at the PR for kitgen, great stuff! I noticed though that there is no full example of how to use it to build a real service. Do you think it would make sense to add?
Additionally, I wonder why the makeEndpoint functions are not exported... I would use them from the main.go in a similar fashion like that:

package main

import (
	"net/http"
	"os"

	kit_http "test/foo/http"

	"test/foo/endpoints"
	"test/foo/service"

	"github.com/go-kit/kit/log"
)

func main() {
	logger := log.NewLogfmtLogger(os.Stderr)

	var svc service.Service
	svc = service.ServiceStruct{}

	e := endpoints.Endpoints{}

	e.Concat = endpoints.MakeConcatEndpoint(svc)
	e.Sum = endpoints.MakeSumEndpoint(svc)

	handler := kit_http.NewHTTPHandler(e)

	http.Handle("/", handler)
	logger.Log("msg", "HTTP", "addr", ":8080")
	logger.Log("err", http.ListenAndServe(":8080", nil))
}

I'm probably wrong and there is another way to do that, and I think that a full example with a main.go would help to understand that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions