Skip to content

thevxn/swis-nexus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swis-nexus

Go Reference Go Report Card

A simple client/connector for swis-api RESTful JSON API.

A complete example implementation can be find in cmd/swis-nexus/main.go file.

import a usage

go get go.vxn.dev/swis-nexus/pkg/nexus
package main

import (
    "fmt"

    "go.vxn.dev/swis-nexus/pkg/nexus"
)

var (
    client *nexus.Client

    baseURL = "https://swapi.example.com"
    token   = "xxx"
    verbose = true
)

func main() {
    // Fetch a new nexus.Client instance.
    client = nexus.NewClient(baseURL, token)

    // Enable the verbose mode.
    client.Verbose = true

    // Compose a DTO-in object.
    input := &nexus.Input{
        Path: "/users",
        Data: nil,
    }

    // Prepare a DTO-out object.
    output := &nexus.Output{}

    // Execute the API call.
    if err := client.Get(input, output); err != nil {
        fmt.Println(err)
    }

    // Print the response code and response message.
    fmt.Printf("%4d: %s", output.Code, output.Message)
}