Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.
/ gap Public archive

Gap is a web framework aimed at removing HTTP boilerplate from your application.

License

Notifications You must be signed in to change notification settings

hugollm/gap

Repository files navigation

Gap

Gap is a web framework aimed at removing HTTP boilerplate from your application.

Docs

Overview

Here's a minimal example of an application with one endpoint:

package main

import (
    "github.com/hugollm/gap"
)

func main() {
    app := gap.New()
    app.Route("GET", "/", helloEndpoint)
    app.Run()
}

type helloInput struct {
    UserAgent string `request:"header,user-agent"`
}

type helloOutput struct {
    Message string `response:"json,message"`
}

func helloEndpoint(input helloInput) (helloOutput, error) {
    return helloOutput{"hello " + input.UserAgent}, nil
}

This endpoint gets the User-Agent header from the request and outputs a hello message on the response body as JSON.

GET /
User-Agent: golang
---
200 {"message": "hello golang"}

Note how the endpoint function does not depend on the framework. Tag annotations take care of binding inputs and outputs to requests and responses. This makes it much easier to write and test your app.

About

Gap is a web framework aimed at removing HTTP boilerplate from your application.

Resources

License

Stars

Watchers

Forks

Languages