Skip to content
/ shiftapi Public

EXPERIMENTAL: Quickly write RESTful APIs in go with automatic openapi schema generation.

License

Notifications You must be signed in to change notification settings

fcjr/shiftapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e7add8c · Jan 7, 2025

History

18 Commits
Oct 23, 2021
Oct 23, 2021
Jan 7, 2025
Oct 24, 2021
Jan 7, 2025
Dec 31, 2024
Jan 7, 2025
Jan 7, 2025
Jan 7, 2025
Jan 7, 2025
Jan 7, 2025
Jan 7, 2025
Jan 7, 2025
Jan 7, 2025
Jan 7, 2025

Repository files navigation

ShiftAPI Logo

ShiftAPI

⚠️ This project is still in development, the API is not stable and is not ready for production use. ⚠️

Quickly write RESTful APIs in go with automatic openapi schema generation.

Inspired by the simplicity of FastAPI.

GolangCI Go Report Card

Installation

go get github.com/fcjr/shiftapi

Usage

    package main

    import (
        "context"
        "errors"
        "log"
        "net/http"

        "github.com/fcjr/shiftapi"
    )

    type Person struct {
        Name string `json:"name"`
    }

    type Greeting struct {
        Hello string `json:"hello"`
    }

    func greet(ctx context.Context, headers http.Header, person *Person) (*Greeting, error) {
        return &Greeting{
            Hello: person.Name,
        }, nil
    }

    func main() {
        ctx := context.Background()
        server := shiftapi.New(shiftapi.WithInfo(shiftapi.Info{
            Title: "Geeter Demo API",
            Description: "It greets you by name.",
        }))

        handleGreet := shiftapi.Post("/greet", greet)
        _ = server.Register(handleGreet) // You should handle errors in production code.

        log.Fatal(server.ListenAndServe(ctx, ":8080"))
        // redoc will be served at http://localhost:8080/docs
    }

About

EXPERIMENTAL: Quickly write RESTful APIs in go with automatic openapi schema generation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages