apache_conf 代码Scot,Steve,Ross和Miles在2015年4月的Indy.rb上写道

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf 代码Scot,Steve,Ross和Miles在2015年4月的Indy.rb上写道相关的知识,希望对你有一定的参考价值。

source 'https://rubygems.org'

gem 'grape'
require 'grape'
require 'json'
require 'securerandom'
class Note
  attr_accessor :id, :title, :body

  def initialize(attrs = {})
    self.id = SecureRandom.uuid
    self.title = attrs[:title]
    self.body = attrs[:body]
  end

  def to_json(an_argument = nil)
    ::JSON.generate(
      {
        id: id,
        title: title,
        body: body
      }
    )
  end
end

module Notey
  class API < Grape::API
    version 'v1', using: :path
    format :json
    # [domain]/api/v1/...
    prefix :api

    resource :notes do
      desc 'create a note'
      post do
        Note.new(params)
      end

      desc 'edit a note'
      put ':id' do
        puts "You updated. Trust us. Here are your params: #{params}"
        Note.new(title: 'first', body: 'totally new content that you sent us.')
      end

      desc 'delete a note'
      delete ':id' do
        puts "Yup, totally deleted a note, too. Totally did it. Congrats!"
        Note.new(title: 'deleted', body: 'bam')
      end

      desc 'return all notes'
      get do
        [Note.new(title: 'First', body: 'All of the contents'), Note.new(title: 'Second', body: 'Some of the contents')]
      end

      desc "Return a note."
      get ':id' do
        Note.new(title: 'First', body: 'All of the contents')
      end
    end
  end
end
require_relative 'api'
run Notey::API

以上是关于apache_conf 代码Scot,Steve,Ross和Miles在2015年4月的Indy.rb上写道的主要内容,如果未能解决你的问题,请参考以下文章

使用 SPARQL 从公开数据中下载 GeoJSON 边界

邮件相关

Oracle数据库迁移

apache_conf 自定义字体代码

STEVE JOBS: Stanford CommencementStay Hungry. Stay Foolish.

apache_conf 过期标题.htaccess代码。