dittofunc

command module
v0.0.0-...-8c53de1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 4 Imported by: 0

README

dittofunc

HTTP server implementation of Ditto https://github.com/juanvillacortac/ditto code generation.

Usage

// main.go

package main

import (
	"flag"
	"log"
	"net/http"

	"github.com/ethanthatonekid/dittofunc/ditto/httpserver/ditto"
)

var origin = "http://localhost:8080"
var owner = "juanvillacortac"
var repo = "ditto"
var path = "/examples/angular/config.yml"
var ref = "main"
var token string

func main() {
	flag.StringVar(&origin, "origin", origin, "Ditto origin")
	flag.StringVar(&owner, "owner", owner, "GitHub owner")
	flag.StringVar(&repo, "repo", repo, "GitHub repo")
	flag.StringVar(&path, "path", path, "GitHub path")
	flag.StringVar(&ref, "ref", ref, "GitHub ref")
    flag.StringVar(&token, "token", token, "GitHub token")
	flag.Parse()

	// Create a new client.
	client := ditto.New(*http.DefaultClient, origin)

	// Create a new query.
	q := ditto.NewGenQuery(token, owner, repo, path, ref)

	// Execute the query.
	generated, err := client.Gen(q)
	if err != nil {
		log.Fatalln(err)
	}

	// Print the generated code.
	log.Println(generated)
}
# Spin up the server locally.
go run .

# Make a request to the server.
go run examples/hello_world/main.go -token=...

Server

The Ditto httpserver.Handler is a simple HTTP handler that receives a Ditto configuration file from GitHub and generates the code.

Requirements:

go run .

Deployment

Netlify

Netlify is a great option for hosting the server.

Visit the Netlify website and create an account.

Get started with a new site from GitHub.

Select the GitHub repository and branch.

Set the base directory to internal/netlify.

Ignore the build command and publish directory.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples
angular command
Run: go run examples/angular/main.go -token=...
Run: go run examples/angular/main.go -token=...
hello_world command
internal

Jump to

Keyboard shortcuts

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