FernandoCelmer / api.go

API.go

Home Page:https://fernandocelmer.github.io/api.go/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api.go



Installation

To install, simply run:

go get github.com/FernandoCelmer/api.go

Required imports

package main

import (
	"encoding/json"
	"fmt"
	"net/http"

	web "github.com/FernandoCelmer/api.go/src"
)

Simple Example

func main() {
	app := web.NewApp()
	app.Get("/item", itemHandler)

	app.Run()
}

Example with parameters

func main() {
	app := web.NewApp(
		web.Title("API"),
		web.Description("Minimalist API Test"),
		web.Version("0.1.0"),
	)

	app.Get("/item", itemHandler)

	app.Run(
		web.Host("127.0.0.5"),
		web.Port(8080),
	)
}

Handler implementation

type Response struct {
	Message string `json:"message"`
}

func itemHandler(w http.ResponseWriter, r *http.Request) {
	data := Response{Message: "Item"}
	response, _ := json.Marshal(data)
	fmt.Fprintf(w, string(response))
}

Commit Style

  • ⚙️ FEATURE
  • 📝 PEP8
  • 📌 ISSUE
  • 🪲 BUG
  • 📘 DOCS
  • 📦 PyPI
  • ❤️️ TEST
  • ⬆️ CI/CD
  • ⚠️ SECURITY

License

This project is licensed under the terms of the MIT license.

About

API.go

https://fernandocelmer.github.io/api.go/

License:MIT License


Languages

Language:Go 50.2%Language:HTML 27.4%Language:Python 16.5%Language:JavaScript 4.3%Language:CSS 1.6%