linnil1 / get2post

A Go service that transform GET to POST. Work on Lambda.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GET to POST service in GoLang

Flow: GET (query) -> aws APIGateway -> aws Lambda -> Lambda web adapter -> GoLang Binary -> check secret -> POST (json) -> target web

Deploy

sam build
sam deploy --guide --parameter-overrides SECRET={{password}}

Then try it out with httpbin:

curl "https://{{your_apigateway_id}}.execute-api.{{your_region}}.amazonaws.com/get2post?secret={{password}}&url=https://httpbin.org/post&data.content=Test%20from%20aws&data.user.name=Testing&data.user.id=123"

The resulting POST body will be structured as follows:

{
  "content": "Test from aws",
  "user": {
    "id": "123",
    "name": "Testing"
}

Parameter Explanations:

  • secret: The required password for activating the service. Leave it empty if SECRET is not provided.
  • url: The destination URL for posting JSON data.
  • method: The destination METHOD (default: POST)
  • data.*: Parameters for supplying flattened POST data. Refer to https://github.com/nqd/flat for syntax details.
  • header.*: Parameters for supplying flattened HEADER. Refer to https://github.com/nqd/flat for syntax details.

Environment

License

MIT License

Copyright (c) 2023 linnil1

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A Go service that transform GET to POST. Work on Lambda.


Languages

Language:Go 98.5%Language:Makefile 1.5%