Questions tagged [martini]

Martini is a popular, lightweight web framework for Go.

Martini is a powerful package for quickly writing modular web applications/services in Go.

More information: https://github.com/codegangsta/martini

Contributed add-ons: https://github.com/codegangsta/martini-contrib

69 questions
21
votes
3 answers

Restart Go's net/http server on file-change like Django

I'm trying out Martini, which adds some nice functionality upon Go's basic net/http package. I was wondering tho. How can I, like Django does too, let the server restart itself on source-file changes? I know how to monitor a file, but I'm not sure…
user1467267
14
votes
1 answer

Postgresql Parameter Issue $1

I am working on setting up a database, building a custom Upsert as Postgresql apparently doesn't have that yet. Anyway my parameters aren't playing nicely. I am using Martini. This code: func CreateBook(ren render.Render, r *http.Request, db…
Sam
  • 203
  • 1
  • 4
  • 13
14
votes
1 answer

How can I render markdown to a golang template(html or tmpl) with blackfriday?

I use the Martini framework,I have some markdown file and I want render it as HTML in tmpl/html template. The markdown file like this: title: A Test Demo --- ##ABC > 123 And the template file like this: …
AriesDevil
  • 277
  • 4
  • 7
  • 19
9
votes
1 answer

Go simple API Gateway proxy

I've been searching all over the internet how to do this, but I haven't been able to find it. I'm trying to build a simple API gateway using Go and Martini for my system that has a few microservices with REST interfaces running. For example, I have…
Dirk
  • 2,094
  • 3
  • 25
  • 28
5
votes
1 answer

image.Decode results in "unknown format" when source is multipart.File

I have a multipart.File that a user uploads to my server, and then I take that file and upload it to s3 using aws-sdk-go, but I also want to create a thumbnail of that image. The code below works fine in my tests when I file is the return value of…
markmarkoh
  • 507
  • 5
  • 11
5
votes
2 answers

read from secondary with mgo.Monotonic

I am trying to configure reading from primary and two secondary nodes of mongo replica set to provide better load balancing. Each of 3 nodes are on different machines with IP addresses: ip1, ip2, ip3. My GoLang site, which is the martini web server…
Maxim Yefremov
  • 13,671
  • 27
  • 117
  • 166
5
votes
1 answer

How to get a function-duration breakdown in go (profiling)

Update (Jan 24, 2019): This question was asked 4 years ago about Go 1.4 (and is still getting views). Profiling with pprof has changed dramatically since then. Original Question: I'm trying to profile a go martini based server I wrote, I want to…
Ronna
  • 1,150
  • 14
  • 24
4
votes
1 answer

Martini oauth2callback redirects to oauth2error after adapting to GAE

Code below works perfectly on local server, but when adapted to Google app engine(func main is changed to init and package name is set from main to test app) oauth2callback request is not working anymore, below request is redirected to oauth2error…
denizeren
  • 934
  • 8
  • 20
3
votes
1 answer

how to dynamically render as HTML/JSON/XML in golang with martini?

I am trying to have a simple REST API server in golang site which serves HTML, JSON or XML format of the same date as requested by client. I am not able to figure out. I hope I am not doing something silly. Code: package main import ( …
FlowRaja
  • 677
  • 3
  • 6
  • 15
3
votes
2 answers

Pipe a HTTP response

How do I pipe an HTTP response like in NodeJS. Here is the snippet I am using in NodeJS: request({ url: audio_file_url, }).pipe(ffmpeg_process.stdin); How can I achieve the same result in Go? I am trying to pipe a audio stream from HTTP into an…
viperfx
  • 327
  • 5
  • 17
3
votes
1 answer

Serve a decoded image via Martini

I am currently playing around with golang and Martini and such and wanted to dynamically serve some manipulated/generated images. Here's a minimal example: package main import ( "github.com/codegangsta/martini" "github.com/nfnt/resize" …
sontags
  • 3,001
  • 3
  • 19
  • 25
3
votes
2 answers

Accessing JSON received via POST from file

I'm building a RESTful API using Martini and have a hard time accessing the contents of book.json sent to my service via curl -X POST "http://localhost:8080/books" -H "Content-Type: application/json" -d @book.json book.json is not a binary file but…
Ralf
  • 2,512
  • 4
  • 24
  • 26
2
votes
1 answer

How to break-out of martini middleware

In short, if I run some middleware for an http.Request and determine that the request deserves an HTTP 422, how can I "break-out" out of the middleware chain, and return early without invoking all of the middleware functions in the chain? For…
user12374570
2
votes
1 answer

How to test reverse proxy with martini in go

I'm writing test code for martini app working as a reverse proxy in go, and want to test it using httptest.ResponseRecorder, but I got an error the following. [martini] PANIC: interface conversion: *httptest.ResponseRecorder is not…
Takamario
  • 105
  • 2
  • 7
2
votes
1 answer

Martini routes with named parameter fails static files loading

I wrote my first Go application with Martini. I have route with named parameter: m := martini.Classic() staticOptions := martini.StaticOptions{Prefix: "assets"} m.Use(martini.Static("assets", staticOptions)) m.Get("/edit/:id",…
Sergei Stralenia
  • 855
  • 7
  • 16
1
2 3 4 5