Giter Site home page Giter Site logo

atc-server's Introduction

ATC Server made with Go

Running

With docker

Make sure you have docker installed.

You can either pull the image from dockerhub:

docker run -p 9000:9000 --name atc-server arturhnat/atc-server:latest

or after cloning this repo, you can:

  1. Build the image
docker build -t atc-server .
  1. Run the image
docker run -p 9000:9000 atc-server
  1. Your server will now be available at http://localhost:9000/

With Go

Make sure you have go installed.

  1. Download modules
go mod download
  1. Install modules
go install .
  1. Run the server
go run main.go

Usage

The server has 4 main routes:


Adding more sites

All supported sites are configured in the config.json file and are loaded dynamically, so to add a new site for either ATC/ Wishlist, all you need to do is add the proper URLs to the config file.

If you'd want to add another site to the locale picker, all you need to do is add an entry into the router file. You may also want to configure the setLocaleHandler function.

Each site in the config file is expected to have the following structure:

"name_of_the_site": { // this will then be the required query parameter for the /atc and /wishlist routes
    "run_script": true, // whether or not the default form handler should be overwritten with a different script, specified by the script_name below
    "script_name": "site.js", // name of the script to execute
    "atc_supported": true, // whether or not Adding to Cart is supported
    "wishlist_supported": true, // whether or not Adding to Wishlist is supported
    "wait_for_submit": false, // Whether or not should the script wait for the form to finish submitting before redirecting
    "locales": { // each entry in the locales object is understood as a new locale. There always has to be at least one, default one named 'default'.
      "default": {
        "atc_url": "https://site.com/add-to-cart", // URL to which the ATC form gets POSTed
        "atc_redirect_url": "https://site.com/checkout", // URL to which the user will be redirected after ATC, can be anything
        "wishlist_url": "https://site.com/add-to-wishlist", // URL to which the Wishlist form gets POSTed
        "wishlist_redirect_url": "https://site.com/wishlist", // URL to which the user will be redirected after ATC, can be anything
      }
    }
  }

atc-server's People

Contributors

rtunazzz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

atc-server's Issues

Having some problem deploying this to Heroku.

remote: -----> Running: go install -v -tags heroku -mod=vendor github.com/bonzayio/go-atc-server
remote: github.com/go-chi/chi
remote: # github.com/go-chi/chi
remote: vendor/github.com/go-chi/chi/tree.go:60:20: invalid operation: 2 << n (shift count type int, must be unsigned integer)
remote: ! Push rejected, failed to compile Go app.
remote:
remote: ! Push failed
remote: Verifying deploy...

Getting this error, would you know what is causing this? To me, this looks like an error with the dependency, not sure, didn't get this running locally.

Very new to Go and control, and was using your source code to post ATC requests to cart products on local retailers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.