Skip to content
A powerful web SDK builder for go, like retrofit for java
Go AMPL
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
headers
mock
testAssets
unmarshalers
.gitignore
.travis.yml
Checker.go
Client.go
Creator.go
ErrorMessages.go
LICENSE
README.md
Reader.go
RequestFields.go
Response.go
TagKeys.go
Unmarshaler.go
UrlCtr.go
VarsCtr.go
all_types_test.go
benchmark_test.go
builder_test.go
checker_test.go
creator_test.go
err_test.go
exception_test.go
go.mod
go.sum
interfaceTypes.go
mock_server_test.go
vars_ctr_test.go

README.md

Coverage Status Go Report Card Build Status License: MIT Documentation

Usage

package example

import (
	"fmt"
	"github.com/Hexilee/gotten"
	"net/http"
	"time"
)

type (
	SimpleParams struct {
		Id   int `type:"path"`
		Page int `type:"query"`
	}

	Item struct {
		TypeId      int
		IId         int
		Name        string
		Description string
	}

	SimpleService struct {
		GetItems func(*SimpleParams) (gotten.Response, error) `method:"GET";path:"itemType/{id}"`
	}
)

var (
	creator, err = gotten.NewBuilder().
		SetBaseUrl("https://api.sample.com").
		AddCookie(&http.Cookie{Name: "clientcookieid", Value: "121", Expires: time.Now().Add(111 * time.Second)}).
		Build()

	simpleServiceImpl = new(SimpleService)
)

func init() {
	err := creator.Impl(simpleServiceImpl)
	if err != nil {
		panic(err)
	}
}

func InYourFunc() {
	resp, err := simpleServiceImpl.GetItems(&SimpleParams{1, 1})
	if err == nil && resp.StatusCode() == http.StatusOK {
		result := make([]*Item, 0) 
		err = resp.Unmarshal(&result)
		fmt.Printf("%#v\n", result)
	}
}
You can’t perform that action at this time.