Nano API Implementation in Golang

nanoapi

Nano API Implementation in GO

TL;DR

The idea is to create a very simple API interface on top of standard router like the one shown below.

The implementation relies on top of generics, to make things really simple, as shown below.

nanoapi.HF("b", func(i string) (out time.Time, err error) {
    out = time.Now()
    return
})
http.ListenAndServe(":8080", nil)

Later on you call it as:

res, err = http.Get("http://localhost:8080/b")

if err != nil {
    log.Printf("Err: " + err.Error())
    t.Fatal()
}

Details

In case more control is required, method H (Handler) can be used with a nanoapi.C (C abstracts a Command) struct, like this:

nanoapi.H(&nanoapi.C[string, string]{
		Name: "a",
		F: func(i string) (out string, err error) {
			out = "Got: " + i
			return
		},
		Help: "A function",
	})

Nano api will provide you some methods (in case you call nanoapi.Setup first):

  • __list: lists all available commands

  • __help/cmd: Provides you a JSON object with in, out format , cmd message and Help message (in case you use H to register CMD), like this:

{"name":"b","in":"","out":"0001-01-01T00:00:00Z","help":"Function b"}

Important

At this moment, no methods are bound to API - we want simple Registration is done directly to defaultMux - we want simple It only supports stdlib router - we want simple

Your contribution / feedback is welcome.

Owner
Digital Circle
Digital Circle
Digital Circle
Similar Resources

Golang implementation of Reflective load PE from memory

🐸 Frog For Automatic Scan 🐶 Doge For Defense Evasion & Offensive Security Doge-MemX Golang implementation of Reflective load PE from memory Only Sup

Dec 6, 2022

Golisp-wtf - A lisp interpreter (still just a parser) implementation in golang. You may yell "What the fuck!?.." when you see the shitty code.

R6RS Scheme Lisp dialect interpreter This is an implementation of a subset of R6RS Scheme Lisp dialect in golang. The work is still in progress. At th

Jan 7, 2022

Doge-AddSSP - Load ssp dll golang implementation

Doge-AddSSP Load ssp dll golang implementation Administrator/System Privilege Us

Nov 9, 2022

golang implementation of Syswhisper2/Syswhisper3

Doge-Whisper golang implementation of Syswhisper2/Syswhisper3 按系统调用地址排序获取System Service Number(SSN)即为sysid以绕过hook, Sorting by System Call Address doge

Dec 10, 2022

An implementation of sed in Go. Just because!

Sed-Go An implementation of sed in Go. Just because! Status Command-Line processing: Done. It accepts '-e', '-f', '-n' and long versions of the same.

Aug 23, 2022

Reference go implementation of globalDCE protocol

globalDCE-go This is the reference implementation of the command line interface of globalDCE coded in the go programming language. This project is sti

Nov 15, 2021

Reference implementation of globaldce protocol coded in go

globaldce This is the reference implementation of the command line interface of globaldce coded in the go programming language. This project is still

Nov 15, 2021

A go language implementation of a CLI, based on input directory files

A go language implementation of a CLI, based on input directory files, using tree output of all file names, based on input database links, dynamic reading of database table information, based on input swagger files to automate the generation of the RESTFUL API.

Aug 23, 2022

An experimental AOT implementation of PHP

Trunk An experimental PHP implementation that transpiles PHP code into Go code.

Dec 31, 2022
Related tags
A tiny Nano wallet, focused on ease of use through simplicity

atto is a tiny Nano wallet, which focuses on ease of use through simplicity. Disclaimer: I am no cryptographer and atto has not been audited. I cannot

Nov 14, 2022
A Nano ID command line (CLI) tool implemented in Go.

Nano ID CLI The Nano ID CLI is a command line tool for generating Nano IDs. With Nano ID CLI you can quickly generate one or more Nano ID strings of a

Nov 15, 2022
GDScript Syntax Highlighting in GNU Nano

nano-gdscript GDScript Syntax Highlighting in GNU Nano. Updated regularly every minor updates. Contributions are welcomed Installation This is 100% fr

Dec 20, 2022
Vanity address generator for Nano

Nano Vanity Generator A basic vanity address generator for the Nano cryptocurrency. What is a vanity address? A vanity address is an address that cont

Feb 6, 2022
Simple to do list API with Gin and Gorm (with Postgres)Simple to do list API with Gin and Gorm (with Postgres)

go-todo Simple to do list API with Gin and Gorm (with Postgres) Docker Clone this repository and run: docker-compose up You can then hit the followin

Aug 29, 2022
Go-api-cli - Small CLI to fetch data from an API sync and async

Async API Cli CLI to fetch data on "todos" from a given API in a number of ways.

Jan 13, 2022
Rule engine implementation in Golang
Rule engine implementation in Golang

"Gopher Holds The Rules" Grule-Rule-Engine import "github.com/hyperjumptech/grule-rule-engine" Rule Engine for Go Grule is a Rule Engine library for t

Jan 3, 2023
Readline is a pure go(golang) implementation for GNU-Readline kind library
Readline is a pure go(golang) implementation for GNU-Readline kind library

A powerful readline library in Linux macOS Windows Solaris Guide Demo Shortcut Repos using readline Feedback If you have any questions, please submit

Jan 8, 2023
Simple trie based auto-completion engine implementation in golang.
Simple trie based auto-completion engine implementation in golang.

Simple auto-complete engine implementation in golang. Quick start $ git clone https://github.com/benbarron/trie-auto-completion-engine $ cd trie-auto-

Jul 12, 2022
Golang implementation of the research by @jonaslyk and the drafted PoC from @LloydLabs

Doge-SelfDelete Golang implementation of the research by @jonaslyk and the drafted PoC from @LloydLabs Golang 实现的文件自删除,来自@jonaslyk和@LloydLabs etc add

Oct 2, 2022