utils

command module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

README

Akkurate utils

Simple http server

package main

import (
	"github.com/Akkurate/utils/http/apiserver"
	"github.com/Akkurate/utils/logging"
)

// Routes Routes
type Routes struct {
}

func (r *Routes) helloWorld() map[string]string {
	return map[string]string{"hello": "world"}
}
func (r *Routes) RouteIndex(c *apiserver.Context) {
	logging.Info("coming in here")
	a := r.helloWorld()
	a["id"] = c.GetParam("id").AsString()
	c.SendJSON(a)
}

func main() {
	routes := &Routes{}
	routeMapping := map[string]apiserver.RouteHandler{
		"get /:id": routes.RouteIndex,
	}
	server := apiserver.NewAPIServer(&apiserver.APIServerProps{
		Port: "7777",
	})
	server.Start(routeMapping)
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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